新人请教,win7下安装的问题!
发布于 3年前 作者 andrew 4185 次浏览

高手帮我看看这些错误是怎么回事?

C:\Users\HL>npm install

npm ERR! Couldn't read dependencies.

npm ERR! Error: ENOENT, no such file or directory ‘C:\Users\HL\package.json’ npm ERR! 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! npm ERR! System Windows_NT 6.1.7601 npm ERR! command “C:\Program Files\nodejs\\node.exe” “C:\Program Files\nod ejs\node_modules\npm\bin\npm-cli.js” “install” npm ERR! cwd C:\Users\HL npm ERR! node -v v0.6.9 npm ERR! npm -v 1.1.0-3 npm ERR! path C:\Users\HL\package.json npm ERR! code ENOENT npm ERR! message ENOENT, no such file or directory ‘C:\Users\HL\package.json’ npm ERR! errno {} npm ERR! npm ERR! Additional logging details can be found in: npm ERR! C:\Users\HL\npm-debug.log npm not ok

C:\Users\HL>npm install formidable

npm http GET https://registry.npmjs.org/formidable

npm ERR! Error: failed to fetch from registry: formidable npm ERR! at C:\Program Files\nodejs\node_modules\npm\lib\utils\npm-registry- client\get.js:139:12 npm ERR! at cb (C:\Program Files\nodejs\node_modules\npm\lib\utils\npm-regis try-client\request.js:32:9) npm ERR! at Request.callback (C:\Program Files\nodejs\node_modules\npm\lib
utils\npm-registry-client\request.js:137:18) npm ERR! at Request.callback (C:\Program Files\nodejs\node_modules\npm\node
modules\request\main.js:109:22) npm ERR! at Request.<anonymous> (C:\Program Files\nodejs\node_modules\npm\no de_modules\request\main.js:198:58) npm ERR! at Request.emit (events.js:88:20) npm ERR! at ClientRequest.<anonymous> (C:\Program Files\nodejs\node_modules
npm\node_modules\request\main.js:195:10) npm ERR! at ClientRequest.emit (events.js:67:17) npm ERR! at CleartextStream.<anonymous> (http.js:1134:11) npm ERR! at CleartextStream.emit (events.js:67:17) npm ERR! 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! npm ERR! System Windows_NT 6.1.7601 npm ERR! command “C:\Program Files\nodejs\\node.exe” “C:\Program Files\nod ejs\node_modules\npm\bin\npm-cli.js” “install” “formidable” npm ERR! cwd C:\Users\HL npm ERR! node -v v0.6.9 npm ERR! npm -v 1.1.0-3 npm ERR! message failed to fetch from registry: formidable npm ERR! npm ERR! Additional logging details can be found in: npm ERR! C:\Users\HL\npm-debug.log npm not ok

10 回复

nodejs的win版本自带npm,为什么还要再install一遍啊?想用最新版的直接update就行了

现在已经可以直接安装windows版本了。我目前好像win,linux,mac的环境都有了。哈哈。

新版的nodejs中npm已经是标配了,三个平台下都是一样的。不需要单独安装了。

不过新版的node安装包里虽然已经自带了npm,但用npm在安装某些模块的时候,有的命令还是不能用,比如有可能用到make命令,但其实windows下并没有这个命令,需要另外安装。

假如我程序不安装formidable,会报错的啊:

Error: Cannot find module 'formidable'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (F:\workSpace\Node-http\requestHandlers.js:5:76)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)

安装的话会出现这个错误:

C:\Users\HL>npm install formidable
npm http GET https://registry.npmjs.org/formidable

npm ERR! Error: failed to fetch from registry: formidable
npm ERR!     at C:\Program Files\nodejs\node_modules\npm\lib\utils\npm-registry-
client\get.js:139:12
npm ERR!     at cb (C:\Program Files\nodejs\node_modules\npm\lib\utils\npm-regis
try-client\request.js:32:9)
npm ERR!     at Request._callback (C:\Program Files\nodejs\node_modules\npm\lib\
utils\npm-registry-client\request.js:137:18)
npm ERR!     at Request.callback (C:\Program Files\nodejs\node_modules\npm\node_
modules\request\main.js:109:22)
npm ERR!     at Request.<anonymous> (C:\Program Files\nodejs\node_modules\npm\no
de_modules\request\main.js:198:58)
npm ERR!     at Request.emit (events.js:88:20)
npm ERR!     at ClientRequest.<anonymous> (C:\Program Files\nodejs\node_modules\
npm\node_modules\request\main.js:195:10)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at CleartextStream.<anonymous> (http.js:1134:11)
npm ERR!     at CleartextStream.emit (events.js:67:17)
npm ERR! You may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>
npm ERR!
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "formidable"
npm ERR! cwd C:\Users\HL
npm ERR! node -v v0.6.10
npm ERR! npm -v 1.1.0-3
npm ERR! message failed to fetch from registry: formidable
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\HL\npm-debug.log
npm not ok

高手们指点一下!

npm库的问题,网路不通~,官方的那个源经常无法访问… 用这个http://registry.npmjs.vitecho.com/,切换一下源

npm config set registry “http://registry.npmjs.vitecho.com/

然后再试试

还是不行啊 :

C:\Users\HL>npm config set registry "http://registry.npmjs.vitecho.com/"
npm WARN invalid config registry="��http://registry.npmjs.vitecho.com/��"
npm WARN invalid config Must be a full url with 'http://'

@andrew 提示http地址不对,手工输入以下,你复制的内容可能被编辑器改了…

npm config set registry “http://registry.npmjs.vitecho.com/

建议贴出package.json文件。

回到顶部