The solution to the error
Reason 1: Insufficient permissions
Open a terminal as an administrator and execute the command.
Reason 2: cache error
method 1
- Delete the .npmrc file under C:\Users{account}\
- Delete the node_modules folder
- Excuting an order
npm cache clean -f
- Then execute the install command
Method 2
- Delete the node_modules folder
- Excuting an order
npm cache clean -f
- Restart the computer
- Execute the install command again
Reason 3: The npm version is not enough
- implement
npm install [email protected]
- Execute the installation command
Reason 4: The network is unstable
method 1
- Switch the download source of npm:
npm config set registry https://registry.npm.taobao.org
- Check the current download source:
npm config get registry
, if the result is the Taobao source above, the switch is successful - Execute the install command again
Method 2
- After the installation command add
--registry https://registry.npm.taobao.org
Attach the official source address: registry https://registry.npmjs.org/
Reason 5: Antivirus software issues
method 1
Turn off the anti-virus software, and then run this installation command several times
Method 2
- Find the file:
[NODE_HOME]/node_modules/npm/node_modules/graceful_fs/polyfills.js
- Look for the following in it:
if (process.platform === "win32") {
//或者是
if (platform === "win32") {
- Below the found location, modify the file to be
/*
说明:
在这个语句中,有一个超时,在出现错误时进行重试。
问题是,在某些情况下,在超时之后,文件仍然被A/V锁定。
解决方案是去掉超时并让这个语句循环。对先前代码的更改进行了注释:
*/
if (platform === "win32") {
fs.rename = (function (fs$rename) {
return function (from, to, cb) {
var start = Date.now()
var backoff = 0;
fs$rename(from, to, function CB (er) {
if (er
&& (er.code === "EACCES" || er.code === "EPERM")
/*&& Date.now() - start < 60000*/) {
console.log("Retrying rename file: " + from + " <> " + to)
fs$rename(from, to, CB);
/*setTimeout(function() {
fs.stat(to, function (stater, st) {
if (stater && stater.code === "ENOENT")
fs$rename(from, to, CB);
else
cb(er)
})
}, backoff)*/
if (backoff < 100)
backoff += 10;
return;
}
if (cb) cb(er)
})
}})(fs.rename)
}