webpack: Webpack doesn't seem to find module when absolute context path is not based off current directory
My folder structure looks like this:
project
app
public
entry.coffee
build
webpack.config.js
dist
test
My webpack.config.js looks like this:
module.exports = {
cache: true,
context: path.resolve(__dirname + "/../app/public"),
entry: "./entry.coffee",
...
I’m receiving this error:
ERROR in Entry module not found: Error: Cannot resolve file or directory ./entry.coffee in /usr/local/webprojects/webpack/app/public
but the file ‘/usr/local/webprojects/webpack/app/public/entry.coffee’ does exist.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 28 (6 by maintainers)
Run it with
--display-error-details
and it says why it cannot resolve it.No and probably never was. Close it.
@lancekuttner you could have used
resolve
inwebpack.config.js
to allow.jsx
extensions:This error may be caused by a syntax error in
package.json
.For me this happened because in my
entry
object I wrote:While I should have written one of these:
The problem was that
path.resolve
will ignore any parameters given to it before the last parameter that starts with a/
.So
path.resolve(__dirname, '/test.js')
, will return/test.js
instead of/path/of/your/project/directory/test.js
.What is the problem in this webpack entry?
I just ran into this using the CLI.
is valid, but
fails with this error. The solution is to specify the full relative path:
could also happen if you haven’t installed
babel-loader
This happened to me, and this issue was that had the following:
… instead of:
See if you can even find the difference (and once you do, see if it should even matter… relative paths should be considered to be rooted at whatever “./” is by whatever is interpreting the relative path… no?)
I had to ensure that I displayed the full extension e.g. ‘./MyComponent.jsx’ instead of ‘./MyComponent’
@towry is the best in the world forgot a comma in .json
My json is fine linted ok. I have the following structure ROOT/src/entry.js
ROOT:webpack.config.js module.exports = { entry: ‘./src’, output: { path: ‘build’, filename: ‘bundle.js’, }, };
I tried …/src /src and src so I am a bit at a loss…anyone any ideas ? TY
[SOLVED FOR ME] I need to actually state the entry
entry: ‘./src/entry.js’,
Thanks. Mine was. Turns out I was using
webpack build
instead of justwebpack
as my command, which strangely gave me the same error and led me here…package.json needs to be in valid JSON syntax On Sep 17, 2015 10:32, “Ameen Soleimani” notifications@github.com wrote: