Could not install from “node_modules\xxx“ as it does not contain a package.json

❤Could not install from "node_modules\xxx" as it does not contain a package.json file.【npm 导致的错误】

详情的错误信息如下图:

Could not install from "node_modules\html-pdf-adaptive\node_modules\jspdf\file-saver@github:eligrey\FileSaver.js#1.3.8" as it does not contain a package.json file.

具体造成过程: 电脑管家清理了一下垃圾 然后跑不起来项目说依赖里面缺pakeage.json 文件,我删了依赖重新装,无法安装。 然后我重新装了环境,也不行

1、清除npm缓存的方式

js 复制代码
(1)
npm cache verify 
(2)
npm cache clear -f
(3)
npm cache clean --force 

清除一下以后重新npm install安装依赖,不过显示的还是跟之前一样

没成功

2、重新安装一下install

js 复制代码
npm install -g install

重新npm install安装依赖 没成功

3、建缓存日志目录,解决可能是因为缓存日志路径出错。

js 复制代码
npm config get cache 查看到我们的node路径

新建文件夹
node_global
node_cache

npm config set prefix "D:\ProgramFiles\nodejs\node_global";
npm config set cache "F:\ProgramFiles\nodejs\node_cache";

重新npm install安装依赖 没成功

4、yarn思考

js 复制代码
npm install yarn

没成功

5、思考拿掉package-lock.json文件,删除锁定依赖

解决办法:删掉项目文件夹中的package-lock.json文件,先后运行npm install -g及npm install命令

重新npm install安装依赖

js 复制代码
重新执行
npm install

错误出现提示 打开日志: 提示我

js 复制代码
Command failed: git clone --depth=1 -q -b 1.3.8 https://github.com/eligrey/FileSaver.js.git D:\ProgramFiles\_cacache\tmp\git-clone-6988743c --config core.longpaths=true
npm ERR! warning: templates not found in C:\Users\Administrator\AppData\Local\Temp\pacote-git-template-tmp\git-clone-20852621
npm ERR! error: RPC failed; curl 28 OpenSSL SSL_read: Connection was reset, errno 10054
npm ERR! fatal: error reading section header 'shallow-info'

RPC failed; curl 28 OpenSSL SSL_read: Connection was reset, errno 10054

大致意思就是网络波动导致的错误

于是我重新进行安装

询问了群里的小伙伴,于是Github上面找到了官方的解答

github.com/eligrey/Fil...

解决方法下面提出来就是删除.lock文件,然后重新安装!

相关推荐
Vicky&James2 分钟前
WPF到Web的无缝过渡:英雄联盟客户端项目OpenSilver迁移实战
前端·wpf
m0_748233646 分钟前
RabbitMQ 进阶
android·前端·后端
不想有bug的小菜鸟15 分钟前
vue3使用iframe全屏展示pdf效果
前端·pdf
m0_7482386315 分钟前
Spring Boot项目接收前端参数的11种方式
前端·spring boot·后端
u01005596016 分钟前
前端代理,解决跨域问题讲解
前端
quitv21 分钟前
react脚手架配置别名
前端·javascript·react.js
m0_5287238130 分钟前
前端如何进行性能优化
前端·性能优化
化作繁星31 分钟前
在 Vue 3 中,如何缓存和复用动态组件
前端·vue.js·缓存
一粒沙-1 小时前
iOS 将GIF图分享至微信
前端·ios
graywen1 小时前
从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
前端