安装Firebase Cloud Functions依赖时遇npm 404错误求助
安装Firebase Cloud Functions依赖时出现404错误:找不到database-debug.log
环境信息
- NodeJS:14.20.1
- npm:9.1.3
- firebase-tools:11.16.1
package.json内容
{ "name": "functions", "type": "module", "scripts": { "build": "tsc", "emulators:start": "firebase emulators:start", "emulators:stop": "lsof -t -i:5000 -i:5001 -i:4030 -i:9099 -i:9001 -i:9199 -i:8091 -i:9090 | xargs kill -9", "serve": "npm run build && firebase emulators:start --only functions", "shell": "npm run build && firebase functions:shell", "start": "npm run shell", "test": "mocha --reporter spec --timeout 10000", "deploy": "firebase deploy --only functions", "logs": "firebase functions:log" }, "engines": { "node": "14" }, "main": "lib/index.js", "dependencies": { "@babel/core": "^7.20.5", "@babel/preset-env": "^7.20.2", "@babel/runtime": "^7.20.6", "@firebase/app-compat": "^0.1.28", "@google-cloud/tasks": "^3.0.5", "@types/rimraf": "^3.0.2", "acorn": "^8.8.1", "axios": "^0.27.2", "chai": "^4.3.4", "csv-parse": "^5.2.1", "firebase-admin": "^11.3.0", "firebase-functions": "^4.1.0", "fs": "0.0.1-security", "mocha": "^9.1.3", "puppeteer": "^10.4.0", "rimraf": "^3.0.2", "typescript": "4.3.5", "typesense": "^1.3.0" }, "devDependencies": { "firebase-functions-test": "^0.3.3" }, "private": true }
错误日志片段
2781 verbose stack HttpErrorGeneral: 404 Not Found - GET https://registry.npmjs.org/database-debug.log - Not found 2781 verbose stack at /home/wpghijsen/.nvm/versions/node/v14.20.1/lib/node_modules/npm/node_modules/npm-registry-fetch/lib/check-response.js:95:15 2781 verbose stack at processTicksAndRejections (internal/process/task_queues.js:95:5) 2781 verbose stack at async RegistryFetcher.packument (/home/wpghijsen/.nvm/versions/node/v14.20.1/lib/node_modules/npm/node_modules/pacote/lib/registry.js:85:19) 2781 verbose stack at async RegistryFetcher.manifest (/home/wpghijsen/.nvm/versions/node/v14.20.1/lib/node_modules/npm/node_modules/pacote/lib/registry.js:116:23) 2781 verbose stack at async Arborist.[nodeFromEdge] (/home/wpghijsen/.nvm/versions/node/v14.20.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1056:19) 2781 verbose stack at async Arborist.[buildDepStep] (/home/wpghijsen/.nvm/versions/node/v14.20.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:926:11) 2781 verbose stack at async Arborist.buildIdealTree (/home/wpghijsen/.nvm/versions/node/v14.20.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:206:7)
排查情况
已确认npm状态正常,怀疑Node版本兼容性问题,寻求其他解决方法。
解决建议
- 清理npm缓存:执行
npm cache clean --force,清除缓存后重新运行npm install - 删除本地依赖文件:删除
node_modules文件夹和package-lock.json文件,再重新安装依赖。命令如下:
Linux/macOS:rm -rf node_modules package-lock.json && npm install
Windows:rmdir /s node_modules && del package-lock.json && npm install - 降级npm版本:npm 9.x与Node 14存在兼容性问题,尝试降级到npm 8.x:
npm install -g npm@8,之后重新安装依赖 - 更换Node版本:升级到Firebase Functions支持的Node 16 LTS版本,使用nvm切换:
nvm install 16 && nvm use 16,再执行npm install - 检查依赖解析问题:执行
npm ls database-debug.log查看是否有依赖关联到这个不存在的包,针对性调整依赖版本 - 切换npm镜像:临时使用国内镜像加速安装,执行
npm config set registry https://registry.npmmirror.com后重新安装
内容的提问来源于stack exchange,提问作者Willem Ghijsen
相关产品推荐
相关产品推荐

