NPM-Troubleshoot
文章目录

NPM Troubleshoot

NodeJS: 全局安装出现 npm WARN checkPermissions Missing write access to C:\xxx 错误

如果报错是 C 盘, 那么可能是以下原因:

  1. 普通用户安装了 NPM
  2. NPM 安装路径在其他磁盘

解决方式都很简单, 转移到其他有权限的路径即可:

这里将

1
2
npm config set prefix "D:\Tools_For_Work\NodeJS\node_global"
npm config set cache "D:\Tools_For_Work\NodeJS\node_cache"

当然,只需要修改全局模块的路径和 cache 就行

NodeJS: error Unexpected end of JSON input while parsing near ‘…mocha”:”^2.4.5”,”mock’

错误描述

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
G:\Dev\GitRepos\Oschina\NodeServer\Server>create-react-app test

Creating a new React app in G:\Dev\GitRepos\Oschina\NodeServer\Server\test.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

npm ERR! Unexpected end of JSON input while parsing near '...mocha":"^2.4.5","mock'

npm ERR! A complete log of this run can be found in:
npm ERR! D:\Tools_For_Work\NodeJS\node_cache\_logs\2017-12-25T03_45_34_447Z-debug.log

Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.

Deleting generated file... package.json
Deleting test / from G:\Dev\GitRepos\Oschina\NodeServer\Server
Done.

Solutions

八成就是对应 npm 源不正常了
换 cnpm 或者淘宝源试一试

NPM: ‘-registry-npm-taobao-org’ on string ‘{"-registry-npm-taobao-org":""}’

输入 npm config list 查看一下是不是哪里设置错了

删掉对应的源或者把对应的 .npmrc 文件删掉

self signed certificate in certificate chain

升级后 SSL 配置变化了

yarn config set strict-ssl false