我的项目工作得很好..但是在进行git推送后,当我运行gulp
时,我突然遇到错误:
{ [Error: ModuleParseError: Module parse failed:
/Users/xyz/project/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json
Line 1: Unexpected token :
You may need an appropriate loader to handle this file type.
| {"uChars":[128,16 ....
为什么会这样?我卸载并重新安装了这个模块iconv-lite
,但它似乎没有帮助。
我收到了同样的错误。您将要安装JSON加载程序模块。我在这个例子中使用json-loader。
npm install json-loader --save
然后,您需要将此加载器添加到webpack.config.js
module: {
loaders: [
{ test: /\.json$/, loader: "json-loader"}
]
}
我通过对node-fetch
的间接依赖来解决这个问题,并通过在webpack.config.js中添加以下内容来解决这个问题:
externals: {
'node-fetch': 'fetch'
}
删除文件解决了问题。