gpt4 book ai didi

node.js - 无法使用 "npm install"在 Node.js 中安装任何包

转载 作者:IT老高 更新时间:2023-10-28 21:53:52 25 4
gpt4 key购买 nike

我是 Node.js 的新手,我正在学习一些教程。由于某种原因,我无法安装任何新的 Node 模块。

我正在使用:Mac OSX 10.7.4 Node v. 0.8.6NPM v. 1.1.48

我运行 npm install X 并且总是得到一个

npm ERR! fetch failed https://registry.npmjs.org/-/X
npm ERR! Error: 404 Not Found

当我真正去npmjs注册中心时,我可以看到项目页面,但是无论我点击哪个tarball链接,它总是一样的:

{
"error": "not_found",
"reason": "document not found"
}

例如,我尝试通过运行 npm install fs 安装 fs,我得到:

npm http GET https://registry.npmjs.org/fs
npm http 200 https://registry.npmjs.org/fs
npm http GET https://registry.npmjs.org/-/fs-0.0.0.tgz
npm http 404 https://registry.npmjs.org/-/fs-0.0.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/-/fs-0.0.0.tgz
npm ERR! Error: 404 Not Found
npm ERR! at null.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/fetch.js:47:16)
npm ERR! at EventEmitter.emit (events.js:115:20)
npm ERR! at WriteStream.flush (fs.js:1514:12)
npm ERR! at fs.close (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:92:5)
npm ERR! at Object.oncomplete (fs.js:297:15)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>

npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "fs"
npm ERR! cwd /Users/comocomo/Documents/workspace/nodeTest
npm ERR! node -v v0.8.6
npm ERR! npm -v 1.1.48
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/comocomo/Documents/workspace/nodeTest/npm-debug.log
npm ERR! not ok code 0

我尝试了 fs、fs-extra、express 和强大的,都给了我相同的 404 响应。我一定有什么问题,我很确定整个注册表没有损坏。

我使用的是旧注册表吗?我应该在我的配置文件中更改它吗?老实说,我宁愿不开始手动安装,我敢肯定这只是一个小配置问题。

谢谢!

最佳答案

我发现存在证书过期问题:

npm set registry https://registry.npmjs.org/

所以我把它设为 http,而不是 https :-

npm set registry http://registry.npmjs.org/

到目前为止没有任何问题。

关于node.js - 无法使用 "npm install"在 Node.js 中安装任何包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11920571/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com