解决前端启动报错:This is probably not a problem with npm. There is likely additional logging output above.

在执行 npm run dev 运行项目的时候报错:

{"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt@2.1.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\TIAN\AppData\Roaming\npm-cache\_logs\2023-04-09T03_14_30_606Z-debug.log

如果出现这种报错情况,需要重新安装 node_modules 文件夹中的内容 但是在安装前,要把之前的内容都清空掉。

其实大多数的主要问题是 package-lock.json 这个文件,一般使用 1、2、4 步就够了,如果不行在重新 1、2、3、4 步,因为使用了 第3步,在 $ npm install 安装会要点时间,相对较慢。

步骤如下:

1、首先删除 node_modules,可以命令行删除,也可以手动右键删除文件夹。
$ rmdir /s/q node_modules

2、删除 package-lock.json 文件

文件作用:package-lock.json它会在npm更改node_modules目录树或者package.json时自动生成的,它准确的描述了当前项目npm包的依赖树,并且在随后的安装中会根据package-lock.json来安装,保证是相同的一个依赖树,不考虑这个过程中是否有某个依赖有小版本的更新。

3、运行命令
$ npm cache clean --force

4、重新加载
$ npm install

posted @   YOLO_BLOG  阅读(1138)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
点击右上角即可分享
微信分享提示