You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行npm install时持续出现npm ERR! code ENOTCACHED错误求助

解决npm install时的ENOTCACHED错误

错误原因

触发ENOTCACHED错误的核心原因是:当前npm的缓存策略被设置为only-if-cached(仅使用本地缓存),但你要安装的@neo4j/graphql包在本地缓存中不存在,导致请求npm官方源时直接失败。

具体解决步骤

1. 临时绕过缓存限制执行安装

直接运行以下命令,强制使用默认缓存模式拉取依赖:

npm install --cache-mode=default

或者完全跳过缓存重新拉取:

npm install --no-cache

2. 修正npm全局缓存配置(避免后续重复报错)

如果后续仍出现该问题,需要检查并调整npm的缓存相关配置:

  • 查看当前缓存配置:
    npm config list
    
  • 若发现prefer-offline被设为true,或cache-min值过高(大于0),执行以下命令恢复默认设置:
    npm config set prefer-offline false
    npm config set cache-min 0
    

3. 清理缓存后重新安装

如果本地缓存存在损坏,先清理缓存再执行安装:

npm cache clean --force
npm install

错误日志详情

npm ERR! code ENOTCACHED
npm ERR! 请求https://registry.npmjs.org/@neo4j%2fgraphql失败:缓存模式为'only-if-cached'但无可用缓存响应。

94 verbose stack Error: 请求https://registry.npmjs.org/@neo4j%2fgraphql失败:缓存模式为'only-if-cached'但无可用缓存响应。
94 verbose stack at cacheFetch (/apps/\npm\node_modules\npm\node_modules\make-fetch-happen\lib\cache\index.js:12:13)
94 verbose stack at async fetch (/apps/\npm\node_modules\npm\node_modules\make-fetch-happen\lib\fetch.js:98:7)
94 verbose stack at async RegistryFetcher.packument (/apps/\npm\node_modules\npm\node_modules\pacote\lib\registry.js:92:19)
94 verbose stack at async RegistryFetcher.manifest (/apps/\npm\node_modules\npm\node_modules\pacote\lib\registry.js:124:23)
94 verbose stack at async Arborist.[nodeFromEdge] (/apps/\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:1108:19)
94 verbose stack at async Arborist.[buildDepStep] (/apps/\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:976:11)
94 verbose stack at async Arborist.buildIdealTree (/apps/\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:218:7)
94 verbose stack at async Promise.all (index 1)
94 verbose stack at async Arborist.reify (/apps/\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\reify.js:153:5)
94 verbose stack at async Install.exec (/apps/\npm\node_modules\npm\lib\commands\install.js:145:5)
95 verbose cwd /apps/nodeapp
96 verbose Windows_NT 10.0.19044
97 verbose node v16.13.0
98 verbose npm v8.13.2
99 error code ENOTCACHED
100 error 请求https://registry.npmjs.org/@neo4j%2fgraphql失败:缓存模式为'only-if-cached'但无可用缓存响应。
101 verbose exit 1
102 timing npm 完成于979ms
103 verbose unfinished npm timer reify 1664999176573
104 verbose unfinished npm timer reify:loadTrees 1664999176587
105 verbose code 1
106 error 本次运行的完整日志可在以下路径查看:

内容的提问来源于stack exchange,提问作者Morgan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 11:55:21