npm ERR! enoent This is related to npm not being able to find a file.解决

一、问题描述

运行sudo npm install color-name出现如下错误:

npm ERR! path /root/blog/node_modules/color-name

npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access '/root/blog/node_modules/color-name'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 


npm ERR! A complete log of this run can be found in:

npm ERR!     /root/.npm/_logs/2018-05-06T14_39_48_918Z-debug.log

二、解决

1. sudo npm install -g color-name --unsafe-perm=true

2.若方法一无效,将no such file or directory,access中指明的文件路径中的node_modules删除:

rm -r node_modules

然后再重新npm install 安装

你可能感兴趣的:(安装)