无法在 webpackUniversalModuleDefinition 设置未定义的 属性 'esprima'
Cannot set property 'esprima' of undefined at webpackUniversalModuleDefinition
我收到这个错误:
Uncaught TypeError: Cannot set property 'esprima' of undefined
at webpackUniversalModuleDefinition (esprima.js:11)
at esprima.js:12
尝试加载网络应用程序时:
错误发生在这里:
(function webpackUniversalModuleDefinition(root, factory) {
/* istanbul ignore next */
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
/* istanbul ignore next */
else if(typeof exports === 'object')
exports["esprima"] = factory();
else
root["esprima"] = factory(); // ** => error is thrown here
})(this, function() {
// ...
});
作为参考,文件 webpack.config.js
是:
// webpack.config.js
module.exports = {
entry: {
// import: './src/Three.js'
},
mode: 'production',
output: {
path: __dirname,
publicPath: '/',
filename: './build/three.min.js'
},
devServer: {
watchContentBase: true,
publicPath: "/",
contentBase: "./",
hot: true,
port: 9090,
},
};
任何人都可以提供可能出错的线索吗?
错误已通过使用 WebPack script-loader
解决,它加载为简单脚本而不是模块:
我收到这个错误:
Uncaught TypeError: Cannot set property 'esprima' of undefined at webpackUniversalModuleDefinition (esprima.js:11) at esprima.js:12
尝试加载网络应用程序时:
错误发生在这里:
(function webpackUniversalModuleDefinition(root, factory) {
/* istanbul ignore next */
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
/* istanbul ignore next */
else if(typeof exports === 'object')
exports["esprima"] = factory();
else
root["esprima"] = factory(); // ** => error is thrown here
})(this, function() {
// ...
});
作为参考,文件 webpack.config.js
是:
// webpack.config.js
module.exports = {
entry: {
// import: './src/Three.js'
},
mode: 'production',
output: {
path: __dirname,
publicPath: '/',
filename: './build/three.min.js'
},
devServer: {
watchContentBase: true,
publicPath: "/",
contentBase: "./",
hot: true,
port: 9090,
},
};
任何人都可以提供可能出错的线索吗?
错误已通过使用 WebPack script-loader
解决,它加载为简单脚本而不是模块: