Webpack: "ERROR in Entry module not found" for module that exists

Created on 29 Apr 2016  路  3Comments  路  Source: webpack/webpack

Bash log:

~/code/blockai/merkletree$ npm run gh-pages:build

> [email protected] gh-pages:build /Users/olalonde/code/blockai/merkletree
> cd demo && rm -rf dist && webpack

Hash: 396f0bfb9d565b6f60f0
Version: webpack 1.13.0
Time: 25ms

ERROR in Entry module not found: Error: Cannot resolve module 'app.js' in /Users/olalonde/code/blockai/merkletree/demo/src
~/code/blockai/merkletree$ ls /Users/olalonde/code/blockai/merkletree/demo/src
app.js
~/code/blockai/merkletree$ cat demo/webpack.config.js
module.exports = {
  context: `${__dirname}/src`,
  entry: 'app.js',
  output: {
    filename: 'bundle.js',
    path: `${__dirname}/dist`,
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['react', 'es2015'],
        },
      },
    ],
  },
}
~/code/blockai/merkletree$ node --version
v6.0.0

The module exists on the filesystem, etc. but webpack says it can't resolve the module. Here's the content of app.js:

import ReactDOM from 'react-dom'
import React from 'react'

const App = () => (
  <p>hello world!</p>
)

ReactDOM.render(
  <App />,
  document.getElementById('app')
)
question

Most helpful comment

  context: `${__dirname}/src`,
  entry: './app.js',

entry is a module request, app.js will look for a module named app.js in your node_modules

All 3 comments

Hmm, replacing

  context: `${__dirname}/src`,
  entry: 'app.js',

with

  // context: `${__dirname}/src/`,
  entry: `${__dirname}/src/app.js`,

fixed the error. Maybe I'm misunderstanding the meaning of the context option?

  context: `${__dirname}/src`,
  entry: './app.js',

entry is a module request, app.js will look for a module named app.js in your node_modules

Oh, thanks.

Was this page helpful?
0 / 5 - 0 ratings