We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have just started to study Webpack and trying to setup development environment based on Webpack4.
I put one script for executing dev server in package.json like bellow.
package.json
# package.json
"scripts": { "dev": "webpack-dev-server --mode development", }
However, there was an error message like bellow when I execute 'npm run dev' on my terminal.
'npm run dev'
ERROR in ./node_modules/destroy/index.js Module not found: Error: Can't resolve 'fs' in 'D:\webpack-setup\node_modules\destroy' @ ./node_modules/destroy/index.js 14:17-30
So, I installed 'webpack-node-externals' and put configuration in 'webpack.config.js' like bellow.
'webpack-node-externals'
'webpack.config.js'
# install webpack-node-externals module
# npm install --save-dev webpack-node-externals
# webpack.config.js
const nodeExternals = require('webpack-node-externals'); module.exports = { target: 'web', externals: [nodeExternals()] devServer: { host: 'localhost', port: 3000, open: true } };
When a browser was opened, there was an error on a browser like bellow.
Uncaught ReferenceError: require is not defined at eval (external_"url":1) at Object.url (main.js:289) at __webpack_require__ (main.js:20) at Object.eval (webpack:///(:3000/webpack)-dev-server/client?:6:11) at eval (webpack:///(:3000/webpack)-dev-server/client?:249:30) at Object../node_modules/webpack-dev-server/client/index.js?http://localhost:3000 (main.js:97) at __webpack_require__ (main.js:20) at eval (webpack:///multi_(:3000/webpack)-dev-server/client?:1:1) at Object.0 (main.js:190) at __webpack_require__ (main.js:20)
I'm not sure this error is related to 'webpack-node-externals' module or not, but could I get some guide for solving this situation?
The text was updated successfully, but these errors were encountered:
I got that error as well when I added webpack-node-externals. Subsequently removed it and the error is gone. Something weird is going on.
Sorry, something went wrong.
Ah I found the answer. This tool is not meant for projects that run in the browser.
#17
@inspectordanno I don't see this confirmed with the author (@liady).
I found out that externals: [nodeExternals()] is compatible with mode: 'production' and target: 'web'.
externals: [nodeExternals()]
mode: 'production'
target: 'web'
So, why not just exclude the mode property from your webpack config and leave it as its default (production)?
mode
production
Excluding externals: [nodeExternals()] may result in a larger bundle size.
Ugh, I guess it was confirmed by the author in #17
No branches or pull requests
I have just started to study Webpack and trying to setup development environment based on Webpack4.
I put one script for executing dev server in
package.json
like bellow.# package.json
However, there was an error message like bellow when I execute
'npm run dev'
on my terminal.So, I installed
'webpack-node-externals'
and put configuration in'webpack.config.js'
like bellow.# install webpack-node-externals module
# webpack.config.js
When a browser was opened, there was an error on a browser like bellow.
I'm not sure this error is related to
'webpack-node-externals'
module or not,but could I get some guide for solving this situation?
The text was updated successfully, but these errors were encountered: