欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

npm install出现: Unexpected end of JSON input while parsing near 我自己亲自做的 有大用 有大大用

2373 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...urce-map-support":"la'

2373 verbose stack     at JSON.parse (<anonymous>)

2373 verbose stack     at parseJson (D:\Program Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)

2373 verbose stack     at consumeBody.call.then.buffer (D:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50)

2373 verbose stack     at process._tickCallback (internal/process/next_tick.js:68:7)

2374 verbose cwd C:\Users\Administrator\Desktop\ninghao-angular-modules

2375 verbose Windows_NT 6.1.7601

2376 verbose argv "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--quiet"

2377 verbose node v10.16.0

2378 verbose npm  v6.9.0

2379 error Unexpected end of JSON input while parsing near '...urce-map-support":"la'

2380 verbose exit [ 1, true ]



npm install出现: Unexpected end of JSON input while parsing near


执行 # ng new project  报以上的错

我的办法是:

1) nodejs 降级 (还得重新安装在 默信的目录下面,不要修改安装目录)  我不知道什么原因?

2)降级后 要重启电脑吧 

3) 执行 npm cache clean --force  (可以看看下面的红色的字)

4) 再执行 # ng new project



因为最新版的Nodejs与npm版本不合适的问题(因为没更新Node之前是不会的)。解决办法就是把npm的版本降到4版。


在windows下使用cmd执行语句:npm -g i npm@4


Mac系统是在cmd下(windows)执行:npm cache clean --force




 来自  https://blog.csdn.net/document_dom/article/details/88670798



解决npm ERR! Unexpected end of JSON input while parsing near的方法汇总

 阅读约 1 分钟


这两天执行 npm install 时会报错误:

npm ERR! Unexpected end of JSON input while parsing near

这个错误的解决方法有以下几种:

1.删掉package.lock.json

2.清除cache

npm cache clean --force

3.进入下面这个文件夹清除cache
路径:C:/Users/PC/AppData/Roaming/npm-cache
执行:

npm cache clean --force

4.不要用淘宝镜像。

npm set registry https://registry.npmjs.org/

其实我也没搞懂到底是什么问题造成的,有大神给解释一下?

参考资料:https://github.com/vuejs-temp...


来自  https://segmentfault.com/a/1190000015646531



  

普通分类: