Comments (33)
@Keats post on Stackoverflow has a good solution.
set the extensions property on Webpack resolve configuration like this:
webpackConfig.resolve.extensions = ['', '.js', '.coffee'] //ts, or anything else
That solved it for me.
from karma-webpack.
I think Webpack's error are really unfriendly... I tried for half an hour but failed to found out what's wrong when it gives this error.
from karma-webpack.
My problem was not changing the resolve.extensions
option to include .jsx
files.
I've added it to the end of my webpack.config.js
file and it worked:
// other configs...
resolve: {
extensions: [ '', '.js', '.jsx' ]
}
};
from karma-webpack.
HOLY S#!T the issue for me was that I had an extra comma in my package.json
file. Why is THAT hidden behind the --display-error-details
flag?
from karma-webpack.
I was getting this error because my resolve.extensions
extensions were missing dots. "jsx" should be ".jsx", for example.
from karma-webpack.
@eryue0220 What is the error you're receiving?
entry
is expecting a string (or array of strings). Assuming entryFile.js
is in the same directory as your webpack.config.js
, it should read:
module.exports = {
entry: './entryFile.js',
output: {
filename: 'outputFile.js'
}
}
from karma-webpack.
I have the same problem.
from karma-webpack.
Yeah for me "--display-error-details" was a big help and then it turned out that some directory of mine was capitalized whereas my import scripts sources were not.
Also git was not seeing those changes locally so I ended up having to run this from my terminal to be able to commit the directory changes git config core.ignorecase false
from karma-webpack.
Have you added frameworks: ['webpack']
?
from karma-webpack.
+1.
As per @sokra's question, yes we have webpack
in the frameworks array.
Looking at the debug output:
ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' ./tests/run.js in /Users/andrew/Projects/99designs/projects
Something (webpack preloader?) is assuming the files are relative to the path, when they are not. eg: in the above scenario, the file it cannot resolve is at /Users/andrew/Projects/99designs/projects/assets/tests/run.js
, but as of karma-webpack 1.4 the resolution is not working, despite webpack.resolve.root
being set to /Users/andrew/Projects/99designs/projects/assets
.
Here is all karma and webpack config for the codebase I'm currently looking at -- https://gist.github.com/andrewk/b175483507d1c2307b25
from karma-webpack.
Having the same issue even with webpack in frameworks, seems to be related to resolve root too.
from karma-webpack.
I don't think this is wrong. karma resolves the files
array and doesn't know about resolve.root
. It's not expected that entries in the files
array resolve in moduleDirectories
or in resolve.root
. files
is handled by karma.
from karma-webpack.
It's working again 1.5.0
I think if this behaviour is / would have been intentional it should be a new major version since it's a BC break.
from karma-webpack.
I'm also seeing this error on 1.5.1, and I'm unable to make heads or tails of it. For reference, my code is here - you'll need to run npm install and then gulp test.
My directory structure looks like this:
src
├── components
│ ├── content.jsx
│ ├── createItem.jsx
│ ├── createList.jsx
│ ├── deleteList.jsx
│ ├── header.jsx
│ ├── item.jsx
│ ├── list.jsx
│ ├── login.jsx
│ ├── mainMenu.jsx
│ └── notFound.jsx
├── config.js
├── index.jsx
├── mixins
│ └── forceFireLoginMixin.jsx
└── styles
└── elisse.styl
test
├── karma.conf.js
├── specs
│ ├── headerSpec.js
│ └── testSpec.js
└── tests.webpack.js
My karma.conf.js looks like this:
'use strict';
module.exports = function (config) {
config.set({
browsers: ['PhantomJS'],
frameworks: ['jasmine'],
singleRun: true,
files: [
'../src/**/*.{js,jsx}',
'specs/**/*.js'
],
preprocessors: {
'../src/**/*.{js,jsx}': ['webpack', 'sourcemap'],
'specs/**/*.js': ['webpack', 'sourcemap']
},
reporters: ['spec'],
webpack: {
devtool: 'inline-source-map', // in-line source maps instead of the default
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader'
}
]
},
resolve: {
// tell webpack to look for required files in bower and node
modulesDirectories: [
'bower_components',
'node_modules'
],
}
},
webpackServer: {
noInfo: false
},
colors: true,
});
};
When I run karma, I get the following:
Hash: 8344a6c0a9b3c44a5636
Version: webpack 1.9.10
Time: 7ms
webpack: bundle is now VALID.
webpack: bundle is now INVALID.
Hash: 3d83204cffc24f629e2e
Version: webpack 1.9.10
Time: 689ms
Asset Size Chunks Chunk Names
../src/components/createList.jsx 3.56 kB 7 [emitted] ../src/components/createList.jsx
specs/headerSpec.js 1.66 MB 0 [emitted] specs/headerSpec.js
../src/components/header.jsx 2.78 kB 2 [emitted] ../src/components/header.jsx
../src/components/notFound.jsx 1.87 kB 3 [emitted] ../src/components/notFound.jsx
../src/config.js 4 kB 4 [emitted] ../src/config.js
../src/components/content.jsx 2.81 kB 5 [emitted] ../src/components/content.jsx
../src/components/createItem.jsx 3.58 kB 6 [emitted] ../src/components/createItem.jsx
specs/testSpec.js 4.21 kB 1 [emitted] specs/testSpec.js
../src/components/deleteList.jsx 3.27 kB 8 [emitted] ../src/components/deleteList.jsx
../src/components/item.jsx 3.66 kB 9 [emitted] ../src/components/item.jsx
../src/components/list.jsx 4.95 kB 10 [emitted] ../src/components/list.jsx
../src/components/mainMenu.jsx 4.53 kB 11 [emitted] ../src/components/mainMenu.jsx
../src/index.jsx 5.15 kB 12 [emitted] ../src/index.jsx
../src/components/login.jsx 6.19 kB 13 [emitted] ../src/components/login.jsx
../src/mixins/forceFireLoginMixin.jsx 2.8 kB 14 [emitted] ../src/mixins/forceFireLoginMixin.jsx
chunk {0} specs/headerSpec.js (specs/headerSpec.js) 627 kB
[0] ./test/specs/headerSpec.js 748 bytes {0} [built]
[1] ./dev/components/header.js 1.26 kB {0} [built]
[2] ./bower_components/react/react-with-addons.js 625 kB {0} [built]
chunk {1} specs/testSpec.js (specs/testSpec.js) 143 bytes [rendered]
[0] ./test/specs/testSpec.js 143 bytes {1} [built]
chunk {2} ../src/components/header.jsx (../src/components/header.jsx) 1.31 kB [rendered]
[0] ./src/components/header.jsx 1.31 kB {2} [built]
chunk {3} ../src/components/notFound.jsx (../src/components/notFound.jsx) 424 bytes [rendered]
[0] ./src/components/notFound.jsx 424 bytes {3} [built]
chunk {4} ../src/config.js (../src/config.js) 145 bytes [rendered]
[0] ./src/config.js 145 bytes {4} [built]
chunk {5} ../src/components/content.jsx (../src/components/content.jsx) 1.22 kB [rendered]
[0] ./src/components/content.jsx 1.22 kB {5} [built] [1 error]
chunk {6} ../src/components/createItem.jsx (../src/components/createItem.jsx) 1.97 kB [rendered]
[0] ./src/components/createItem.jsx 1.97 kB {6} [built] [1 error]
chunk {7} ../src/components/createList.jsx (../src/components/createList.jsx) 1.94 kB [rendered]
[0] ./src/components/createList.jsx 1.94 kB {7} [built] [1 error]
chunk {8} ../src/components/deleteList.jsx (../src/components/deleteList.jsx) 1.66 kB [rendered]
[0] ./src/components/deleteList.jsx 1.66 kB {8} [built] [1 error]
chunk {9} ../src/components/item.jsx (../src/components/item.jsx) 2.04 kB [rendered]
[0] ./src/components/item.jsx 2.04 kB {9} [built] [1 error]
chunk {10} ../src/components/list.jsx (../src/components/list.jsx) 3.3 kB [rendered]
[0] ./src/components/list.jsx 3.3 kB {10} [built] [1 error]
chunk {11} ../src/components/mainMenu.jsx (../src/components/mainMenu.jsx) 2.89 kB [rendered]
[0] ./src/components/mainMenu.jsx 2.89 kB {11} [built] [1 error]
chunk {12} ../src/index.jsx (../src/index.jsx) 2.21 kB [rendered]
[0] ./src/index.jsx 2.21 kB {12} [built] [11 errors]
chunk {13} ../src/components/login.jsx (../src/components/login.jsx) 4.52 kB [rendered]
[0] ./src/components/login.jsx 4.52 kB {13} [built] [1 error]
chunk {14} ../src/mixins/forceFireLoginMixin.jsx (../src/mixins/forceFireLoginMixin.jsx) 1.21 kB [rendered]
[0] ./src/mixins/forceFireLoginMixin.jsx 1.21 kB {14} [built] [1 error]
WARNING in ./bower_components/react/react-with-addons.js
Critical dependencies:
4:436-443 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ./bower_components/react/react-with-addons.js 4:436-443
ERROR in ./src/components/content.jsx
Module not found: Error: Cannot resolve 'file' or 'directory' ../mixins/forceFireLoginMixin in /Users/quidmonkey/Development/research/elisse/src/components
@ ./src/components/content.jsx 7:33-73
ERROR in ./src/components/createItem.jsx
Module not found: Error: Cannot resolve 'file' or 'directory' ../mixins/forceFireLoginMixin in /Users/quidmonkey/Development/research/elisse/src/components
@ ./src/components/createItem.jsx 7:33-73
ERROR in ./src/components/createList.jsx
Module not found: Error: Cannot resolve 'file' or 'directory' ../mixins/forceFireLoginMixin in /Users/quidmonkey/Development/research/elisse/src/components
@ ./src/components/createList.jsx 7:33-73
ERROR in ./src/components/deleteList.jsx
Module not found: Error: Cannot resolve 'file' or 'directory' ../mixins/forceFireLoginMixin in /Users/quidmonkey/Development/research/elisse/src/components
@ ./src/components/deleteList.jsx 7:33-73
ERROR in ./src/components/item.jsx
Module not found: Error: Cannot resolve 'file' or 'directory' ../mixins/forceFireLoginMixin in /Users/quidmonkey/Development/research/elisse/src/components
@ ./src/components/item.jsx 7:33-73
ERROR in ./src/components/list.jsx
Module not found: Error: Cannot resolve 'file' or 'directory' ../mixins/forceFireLoginMixin in /Users/quidmonkey/Development/research/elisse/src/components
@ ./src/components/list.jsx 7:33-73
ERROR in ./src/components/mainMenu.jsx
Module not found: Error: Cannot resolve 'file' or 'directory' ../mixins/forceFireLoginMixin in /Users/quidmonkey/Development/research/elisse/src/components
@ ./src/components/mainMenu.jsx 7:33-73
ERROR in ./src/index.jsx
Module not found: Error: Cannot resolve module 'components/header' in /Users/quidmonkey/Development/research/elisse/src
@ ./src/index.jsx 3:24-52
ERROR in ./src/index.jsx
Module not found: Error: Cannot resolve module 'components/content' in /Users/quidmonkey/Development/research/elisse/src
@ ./src/index.jsx 5:25-54
ERROR in ./src/index.jsx
Module not found: Error: Cannot resolve module 'components/mainMenu' in /Users/quidmonkey/Development/research/elisse/src
@ ./src/index.jsx 7:26-56
ERROR in ./src/index.jsx
Module not found: Error: Cannot resolve module 'components/login' in /Users/quidmonkey/Development/research/elisse/src
@ ./src/index.jsx 9:23-50
ERROR in ./src/index.jsx
Module not found: Error: Cannot resolve module 'components/createList' in /Users/quidmonkey/Development/research/elisse/src
@ ./src/index.jsx 11:28-60
ERROR in ./src/index.jsx
Module not found: Error: Cannot resolve module 'components/list' in /Users/quidmonkey/Development/research/elisse/src
@ ./src/index.jsx 13:22-48
ERROR in ./src/index.jsx
Module not found: Error: Cannot resolve module 'components/deleteList' in /Users/quidmonkey/Development/research/elisse/src
@ ./src/index.jsx 15:28-60
ERROR in ./src/index.jsx
Module not found: Error: Cannot resolve module 'components/createItem' in /Users/quidmonkey/Development/research/elisse/src
@ ./src/index.jsx 17:28-60
ERROR in ./src/index.jsx
Module not found: Error: Cannot resolve module 'components/item' in /Users/quidmonkey/Development/research/elisse/src
@ ./src/index.jsx 19:22-48
ERROR in ./src/index.jsx
Module not found: Error: Cannot resolve module 'components/notFound' in /Users/quidmonkey/Development/research/elisse/src
@ ./src/index.jsx 21:26-56
ERROR in ./src/index.jsx
Module not found: Error: Cannot resolve module 'mixins/forceFireLoginMixin' in /Users/quidmonkey/Development/research/elisse/src
@ ./src/index.jsx 23:33-70
ERROR in ./src/components/login.jsx
Module not found: Error: a dependency to an entry point is not allowed
@ ./src/components/login.jsx 7:14-34
ERROR in ./src/mixins/forceFireLoginMixin.jsx
Module not found: Error: a dependency to an entry point is not allowed
@ ./src/mixins/forceFireLoginMixin.jsx 7:14-34
webpack: bundle is now VALID.
This error makes no sense. As you can see by my directory structure, the pathing is correct. Ideas?
from karma-webpack.
I'm getting something similar (posted a question on stackoverflow: http://stackoverflow.com/questions/30931713/webpack-karma-cannot-resolve-local-import) , I don't understand this issue either
@quidmonkey did you figure out the issue?
from karma-webpack.
Getting the same issue; I can't understand what the error is supposed to mean. It's telling me that a file with a correct path cannot be found. Anyone?
from karma-webpack.
@evandavis Sorry. Invalid package.json
is propably rar... Nobody made a nice custom error for this...
from karma-webpack.
I just spent an hour or two trying to debug this completely misleading error message :-(
from karma-webpack.
Why is this even reading package.json
? What happens if you don't use npm to manage your dependencies?
from karma-webpack.
Why is this even reading package.json?
because there could be a browser
field which defines overwrites.
What happens if you don't use npm to manage your dependencies?
It's fine when it doesn't find a file.
from karma-webpack.
@moreirayokoyama Thanks! ...was using a striped down Webpack configuration to run tests and forgot about the resolve
property.
from karma-webpack.
@sebald get your game together 😛
from karma-webpack.
from karma-webpack.
@sethlivingston Thank you, I had a similar long standing issue trying to get jsx, ts, and tsx extensions to be resolved correctly and the missing dot apparently was the reason.
from karma-webpack.
Sadly, in webpack 1.12.11 the--allow-incompatible-update
has remove, and the problem is still existing. And I write as follow, it worked:
module.exports = {
entry: [entryFile.js],
output: {
filename: 'outputFile.js'
}
}
But, it throw another error....
from karma-webpack.
resolve by this : http://webpack.github.io/docs/configuration.html#resolve-extensions
from karma-webpack.
- Restart Terminal(Mac) or whatever shell in your environment.
- Add FIXFIX in package.json like this:
"scripts": { "FIXFIX": "webpack --progress --profile --colors --display-error-details --display-cached", },
- Run this: (Yes, with sudo!)
sudo node run FIXFIX
- Now run with your normal build see if it fixed.
from karma-webpack.
Just spent an hour sourcing this problem - was also getting Error: Entry module not found: Error: Cannot resolve 'file' or 'directory'
even though problem was an extra comma in package.json
. Can we get better error handling? Wouldn't be surprised if this issue was more widespread than expected here...
from karma-webpack.
i recently encountered this. The index.html was in another directory. So I just need to resolve the path and it worked.
from karma-webpack.
i recently encountered this
from karma-webpack.
i fixed this problem by setting the working directory to the your_project\src\server instead of your_project\src\server\bin
from karma-webpack.
@eryue0220 What is the error you're receiving?
entry
is expecting a string (or array of strings). AssumingentryFile.js
is in the same directory as yourwebpack.config.js
, it should read:module.exports = { entry: './entryFile.js', output: { filename: 'outputFile.js' } }
This solved my problem... thanks, my entry was missing.
from karma-webpack.
I was getting this error because my
resolve.extensions
extensions were missing dots. "jsx" should be ".jsx", for example.
thanks,i ignore the symbol ',' ...
from karma-webpack.
Related Issues (20)
- karma-webpack 5.0 No longer notified of compilation starting HOT 2
- Cannot read property 'entry' of undefined
- Cannot read property 'entry' of undefined
- karma-webpack 5 fails to read files with a query parameter (e.g. font-awesome) HOT 6
- 5.0 crashes on MacOS (Preprocessor, Plugin), fixed on master -> Release 5.1? HOT 7
- Trying to add karma-webpack to angular karma config HOT 2
- karma.conf.js being treated as entrypoint results in many errors from webpack 5 HOT 2
- Webpack Errors being reported twice.
- Process is not defined HOT 1
- Error during file loading or preprocessing HOT 7
- Webpack file cache isn't generated when webacpack watch option is false/nothing
- karma-webpack does not respect webpack mode = "production" HOT 3
- I have the same problem. HOT 1
- preprocessor change between v4 & v5 leading to error when used with karma-mocha HOT 15
- Issue with Webpack 5 unable to find file 404 (works with webpack 4) HOT 1
- Don't warn overriding [name].js to [name].js
- Figure out a publishing Github Workflow
- Ensure all project dependencies have no auditing issues
- Provide a migration path from karma-webpack
- Update the README.md
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from karma-webpack.