Javascript: Resolving Unexpected Character '#'
Introduction My React app can execute npm run build in development mode (webpack.config.dev.js) but not in production mode (webpack.config.prod.js). The following error is thrown:
Solution 1:
After investigation, I found that the problem came from package.json.
1) Remove the npm and npm-run-all modules from package.json:
2) Remove BannerPlugin from webpack.config.prod.js
// version 1 webpacknew webpack.BannerPlugin("#!/usr/bin/env node", { raw: false }),
// version 2 webpacknew webpack.BannerPlugin({
banner: "#!/usr/bin/env node",
raw: true
});
We don't need these anymore.
3) Use a stable npm- and node version for global execution:
- node v6.9.x
- npm v4.x.x
See this webpack 2 sample (clone and try it locally) and run npm run coba
.
The problem lies within package.json. When the webpack is building in production mode, it will think that the npm and npm-run-all modules are required to include, which they are not.
You should not include npm in package.json as a module, since it is package manager executable.
Post a Comment for "Javascript: Resolving Unexpected Character '#'"