ModuleParseError:模块解析失败:iconv-lite

问题描述 投票:12回答:3

我的项目工作得很好..但是在进行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,但它似乎没有帮助。

encoding npm gulp webpack
3个回答
17
投票

我收到了同样的错误。您将要安装JSON加载程序模块。我在这个例子中使用json-loader

npm install json-loader --save

然后,您需要将此加载器添加到webpack.config.js

module: {
    loaders: [
      { test: /\.json$/, loader: "json-loader"}
    ]
}

3
投票

我通过对node-fetch的间接依赖来解决这个问题,并通过在webpack.config.js中添加以下内容来解决这个问题:

externals: {
    'node-fetch': 'fetch'
}

-1
投票

删除文件解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.