Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ModuleParseError: Module parse failed: iconv-lite

My project was working perfectly fine.. But after doing a git push, I'm suddenly getting an error when I run 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 ....

Why is this happening? I have uninstalled and reinstalled this module iconv-lite, but it doesn't seem to help.

like image 606
Shubham Kanodia Avatar asked Jan 28 '16 11:01

Shubham Kanodia


2 Answers

I received this same exact error. You'll want to install a JSON loader module. I'm using json-loader in this example.

npm install json-loader --save

Then, you need to add this loader to your webpack.config.js

module: {
    loaders: [
      { test: /\.json$/, loader: "json-loader"}
    ]
}
like image 50
user1030152 Avatar answered Oct 19 '22 18:10

user1030152


I had this dependency by an indirect dependency on node-fetch and fixed the issue by adding the following to my webpack.config.js:

externals: {
    'node-fetch': 'fetch'
}
like image 30
Reto Gmür Avatar answered Oct 19 '22 19:10

Reto Gmür