webpack: Error : ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory'...
Hi everybody.
I’m simply trying to use webpack but i can’t solve this error.
This is my webpack.config.js :
module.exports = {
entry: './index.js',
output: {
filename: 'bundle.js'
}
};
I try many thing but nothing change… I’m using last version of webpack 1.8.4.
I got this error :
Running "webpack:build-dev" (webpack) task
Version: webpack 1.8.4
ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' ./index.js in D:\myApp\src
Warning: Task "webpack:build-dev" failed. Use --force to continue.
index.js file is in src folder…
Anybody got an idea ?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 71 (2 by maintainers)
Try running
webpack --display-error-details
. The error may not be related to file resolution.Invisible char issue, not evaluate by npm but cause problem for webpack. Encoding matter.
Had this error today. I’m commenting here because this is the first hit in Google with the error message.
There was nothing wrong with my
webpack.config.js
but there was a syntax error in mypackage.json
which caused this. Better error message would be cool.This error has been seen here too https://github.com/webpack/karma-webpack/issues/33
Man this one really made me regret being a computer programmer. I was able to resolve the issue by changing:
To this:
I think it has to do with the new webpack version where you have to specify “resolve”. My project didn’t work until I added it this line:
resolve: { modulesDirectories: ['node_modules', 'src'], extension: ['', '.js', '.scss'] },
npm install file-loader
fixed the issue for me.Thanks @epeli! Spent a while looking through my gulpfile.js when I had a comma on the last item in my devDependencies in package.json
Terrible error message
I had the error because this:
extenstions: [ '', '.js', '.jsx' ]
. 😵Why does not webpack print such obvious errors as unability to parse package.json? my package.json was corrupted and webpack gave me mysterious errors about unability to resolve absolute path…
wow thanks @jgebhardt --display-error-details saved my bacon
resolve by this : http://webpack.github.io/docs/configuration.html#resolve-extensions
wtf. Had this error because I had one line commented out. with /* … */. Is webpack kidding me?
In my case, the problem was:
entry: path.resolve(__dirname, '/src/index.js'),
instead of:entry: path.resolve(__dirname, 'src/index.js'),
Notice the slash in front of src in the original version.
This was my config:
But I am using Windows and the path was incorrect because Windows uses a backslash.
Fixed with this:
Wow. What a relief! But I should using Node’s Path module to ‘resolve’ this. Will try that next.
For those arriving by search: I had this issue because I was using
html-loader
in my webpack config, and hadrequire
s prefixed withhtml!
. This caused my options in the config to get ignored for every file.I had the same error, help me
Problem here was Case Sensitivity.
FIXED IT BY CHANGING
from
import App from './app';
to thisimport App from './App';
Notice case sensitivity, since my file was App.js
fixed by changing
to
"scripts": { "FIXFIX": "webpack --progress --profile --colors --display-error-details --display-cached", },
sudo node run FIXFIX
I have the same problem beacause of my package.json got a syntax error 😃
I have a similiar issue. Could you please add some more info on the solution?
@techraiders you would add it to your
webpack.config.js
fileThe fix for me was adding “” to my resolve extensions
resolve: { extensions: ["", ".ts", ".tsx", ".js", ".json"], }
I have the error, today. You can check resolve property in you webpack.config.js file: such as:
then, your entry file path is resolve to:
app/index.js
, ornode_modules/index.js
, you need check this file.my problem was missing ./ in the entry path
module.exports = { entry: ‘./src/scripts/main.js’, // before this was just : ‘src/scripts/main.js’ output: { path: __dirname + ‘/build’, bublicPath: ‘/build/’, filename: ‘bundle.js’ } }
I also could solve this problem with the solution @wayofthefuture pointed out. I think this must be bug obviously.