Problem with standart module NodeJS: url module, http, https, zlib,stream my setting file:
webpack: {
custom: {
entry: './src/index.js',
output: {
path: 'build/',
filename: 'index.js'
},
target: 'node',
resolve: {
extensions: [
'.js',
],
root: '.'
},
module: {
loaders: [
{ test: /\.js$/, loader: 'jsx-loader' },
],
}
}
}
After run build and open index.html, and see error in console: Uncaught ReferenceError: require is not defined Opened details, and see:
function(module, exports) {
module.exports = require("url");
},
Also and other standard default module Node.JS: http, https, zlib,stream
require not spun. How it fixed?
Change target 'node' to 'web' ( target: 'web'
). And if using require('fs')
, then necessery using transform loader with brfs: { test: /\\.js$/, loader: 'transform?brfs!}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.