I\'ve started using webpack2 (to be precise, v2.3.2
) and after re-creating my config I keep running into an issue I can\'t seem to solve I get (sorry in advance
I had the same issue, but mine was because of wrong casing in path:
// Wrong - uppercase C in /pathCoordinate/
./path/pathCoordinate/pathCoordinateForm.component
// Correct - lowercase c in /pathcoordinate/
./path/pathcoordinate/pathCoordinateForm.component
I'm building a React server-side renderer and found this can also occur when building a separate server config from scratch. If you're seeing this error, try the following:
Example:
const serverConfig = {
name: 'server',
context: path.join(__dirname, 'src'),
entry: {serverEntry: ['./server-entry.js']},
output: {
path: path.join(__dirname, 'public'),
filename: 'server.js',
publicPath: 'public/',
libraryTarget: 'commonjs2'
},
module: {
rules: [/*...*/]
},
resolveLoader: {
modules: [
path.join(__dirname, 'node_modules')
]
},
resolve: {
modules: [
path.join(__dirname, 'node_modules')
]
}
};
In my case it was a package that was installed as a dependency in package.json
with a relative path like this:
"dependencies": {
...
"phoenix_html": "file:../deps/phoenix_html"
},
and imported in js/app.js
with import "phoenix_html"
This had worked but after an update of node, npm, etc... it failed with the above error-message.
Changing the import line to import "../../deps/phoenix_html"
fixed it.
In my case, to the very end of the webpack.config.js
, where I should exports
the config, there was a typo: export
(should be exports
), which led to failure with loading webpack.config.js
at all.
const path = require('path');
const config = {
mode: 'development',
entry: "./lib/components/Index.js",
output: {
path: path.resolve(__dirname, 'public'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: path.resolve(__dirname, "node_modules")
}
]
}
}
// pay attention to "export!s!" here
module.exports = config;
In my experience, this error was as a result of improper naming of aliases in Webpack.
In that I had an alias named redux
and webpack tried looking for the redux
that comes with the redux package in my alias path.
To fix this, I had to rename the alias to something different like Redux
.
For everyone with Ionic: Updating to the latest @ionic/app-scripts version gave a better error message.
npm install @ionic/app-scripts@latest --save-dev
It was a wrong path for styleUrls in a component to a non-existing file. Strangely it gave no error in development.