0%

解决npm警告、错误的方法记录

记录所遇到过的各种有关npm的问题及其解决方法。


解决npm ERROR! Unexpected end of JSON input while parsing near

1
npm ERR! Unexpected end of JSON input while parsing near

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

1.删掉package.lock.json

2.清除cache

1
npm cache clean --force

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

1
npm cache clean --force

4.不要用淘宝镜像

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

解决WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents):

在安装hexo-deployer-git过程中出现以下问题

1
2
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

fsevent的作用是能够检测文件目录的修改,可以记录恶意软件的非法操作,获取恶意软件的完整路径,删除和修改日期。

原因:fsevent是mac系统的可选依赖,在win或者Linux下使用了,会有警告。在windows上环境下可以忽略,也可以删除fsevent文件夹。


参考

https://www.cnblogs.com/sansancn/p/11139030.html

常见错误|npm文档