I use a corporate computer with Windows 10. I have nodejs v6.10.0 and npm v3.10.10. It's the first time that I install nodejs/npm on this computer.
When I install a module (any kind of modules, for example npm install jsdoc
) then everything works fine. I can call my example.js
several times, and all is OK.
But after a while (random period) I cannot run my program anymore because I get the below error:
>node example.js
module.js:96
throw e;
^
SyntaxError: Error parsing C:\my_path\node_modules\some_module\package.json: Unexpected token x in JSON at position 0
If I check the content of the package.json
with SublimeText I got:
78c0 b658 72a3 e0f5 7832 e7d4 b5ee dcc8
8f00 9951 3b8a cbd5 db7f 4556 5e8b e88d
087d 9bb8 ff15 9acb 0a09 7aaf afd3 ced2
3aa9 e2c5 7e7b c4a1 7b82 a332 2848 83ed
adca d7e8 3228 5537 64eb 3105 2338 6ae2
[...]
And actually it's all the package.json
files under node_modules
for this project that have been corrupted.... For all modules!
However, if I have a package.json
in my project folder, it won't be impacted, only the ones under node_modules
folder will be....
To fix the issue I have to delete node_modules
and reinstall my modules with npm install
. Not really handy. After doing it, my package.json
files are all correct again with the expected content.
I thought it could be related to our McAfee anti-virus, but why it will only impact the package.json
files under node_modules
, and not the ones that are in other folders?
I read somewhere that a corporate proxy could download a package.json
with the wrong encoding, but when I install my modules, the package.json
are totally normal.
So if anyone has any idea/lead, I'll appreciate!
Thanks
via AymKdn
No comments:
Post a Comment