IDEA的npm报错Local package.json exists, but node_modules missing, did you mean to install?

时间:2024-03-14 08:45:33

npm报错Local package.json exists, but node_modules missing, did you mean to install?


问题现象:

今天在使用nodejs项目中配置的npm去启动项目时,出现报错,如下图:

IDEA的npm报错Local package.json exists, but node_modules missing, did you mean to install?


问题分析:

从报错信息就可以很明确的知道报错的原因了,因为vue-cli脚手架没有安装,再者说就是IDEA缺少了npm插件.

所以根据报错信息,进行安装就好了,不过这里有一个坑!


解决方法:

在IDEA的terminal命令窗口处,输入命令: cnpm install

这里强烈推荐使用cnpm 而不是 npm ,因为npm访问的是国外服务器资源,下载速度超慢,容易失败!

cnpm 访问的是国内的淘宝镜像库资源,下载速度快,基本不会失败!

IDEA的npm报错Local package.json exists, but node_modules missing, did you mean to install?

记得配置npm,举例如下:

IDEA的npm报错Local package.json exists, but node_modules missing, did you mean to install?

再重新启动项目,(启动成功的话就是转向箭头图标,启动失败或者未启动过就是三角形播放图标)

IDEA的npm报错Local package.json exists, but node_modules missing, did you mean to install?

启动成功后,会在run控制台窗口看见,类似如下信息:

IDEA的npm报错Local package.json exists, but node_modules missing, did you mean to install?

至此,项目启动成功!