重新安装依赖,npm install报错内容+解决方案

4,689 阅读1分钟

今天将系统升级了,但是vue项目突然报错了,经过nvm node npm cnmp 各种卸载重新安装后,将 cache 文件夹也删除过,终于将 npm 换源 cnpm 后,安装成功了,猜测应该是网络的问题,记录一下,方便以后出现这种错误及时解决

第一种报错情况

报错内容如下:

npm ERR!  ENOENT
npm ERR!  -4058
npm ERR!  chmod
npm ERR!  ENOENT: no such file or directory
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

报错原因:

直接选择了npm install,文件夹层级出错,找不到文件或文件夹

解决方案:

将地址改到项目的那个文件夹 ,指令: cd 文件夹地址

  1. 删除使用npm构建的node_modules文件夹
  2. 运行cmd,转到对应文件夹下,安装淘宝镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org 

  1. 继续运行 cnpm install

  2. 显示安装成功, 之后可运行cnpm run dev