npm不读取.npmrc文件

我试图从一个私人存储库安装一个库,并且在尝试使用npm时不断收到错误。

我正在使用:OSX Mavericks 10.9.3节点v0.10.28 npm 1.4.10(这是安装1.4.13后,它仍然不能正常工作)

我从我的主目录运行这个,并且~/.npmrc文件在目录中。

每当我运行命令: npm install 'library name here'

我得到以下错误:

 npm http GET https://registry.npmjs.org/dslib-js npm http 404 https://registry.npmjs.org/dslib-js npm ERR! 404 404 Not Found: dslib-js npm ERR! 404 npm ERR! 404 'dslib-js' is not in the npm registry. npm ERR! 404 You should bug the author to publish it npm ERR! 404 npm ERR! 404 Maybe try 'npm search dslib' npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, or http url, or git url. npm ERR! System Darwin 13.2.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "dslib-js" npm ERR! cwd /Users/marcos.pedreiro npm ERR! node -v v0.10.28 npm ERR! npm -v 1.4.10 npm ERR! code E404 npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/marcos.pedreiro/npm-debug.log npm ERR! not ok code 0 

编辑:

当我运行ls -a (在主目录中)这是输出:

 . .ssh Music .. .subversion Pictures .CFUserTextEncoding .vagrant.d Public .DS_Store Applications VirtualBox VMs .Trash Desktop clients .bash_history Documents dev .gradle Downloads npm-debug.log .matlab Google Drive ~:.npmrc .npm Library ~:.npmrc.template .npmrc.bak Movies 

这是命令npm config ls -l | grep config的输出 npm config ls -l | grep config

 ; cli configs globalconfig = "/usr/local/etc/npmrc" userconfig = "/Users/marcos.pedreiro/.npmrc" 

:结束编辑

任何帮助将不胜感激。 谢谢!

如果你发布的是真正的ls -a的输出,那么文件名是错误的。

~:.npmrc应该命名为.npmrc

在开始的时候,build议你使用shell快捷方式将文件放在你的主目录下(可能类似于cp .npmrc ~:.npmrc 。问题很可能是冒号, ~/将被解释为“我的主目录”,但~something/将被解释为用户的主目录,因为没有用户的something ,系统可能只是将〜:视为文本文本。

尝试重命名该文件,看看是否可行:

 mv "~:.npmrc" .npmrc 

以防止任何人登陆:我在项目根目录中有一个npm-shrinkwrap.json文件,它覆盖了.npmrcregistryconfiguration。 删除shrinkwrap文件解决了这个问题。

对于运行Windows的用户,请检查Windows是否隐藏文件扩展名。 对我来说,Windows是说文件名是.npmrc ,但真正的文件名是.npmrc.txt

删除.txt扩展名解决了问题。

我假设节点包dslib-js包含在您的私有npm存储库中。 您需要在您的本地.npmrc文件中设置该存储库。 例如,如果您的存储库位于http://myrepo.com:4000 ,则可以运行以下命令:

 $ npm set registry "http://myrepo.com:4000" 

上面的错误是因为dslib-js软件包在dslib-js上不可用,正如您通过访问以下URL所看到的: https ://www.npmjs.org/package/dslib-js。 默认情况下(没有在.npmrc文件中设置registry),npm将searchhttps://registry.npmjs.org (可以通过上面粘贴的URL在Web上浏览)。

如果这有助于任何人……我的问题是我在文本编辑器中创build了.npmrc文件,所以npm忽略了文件,因为它的权限。 为了解决它,我删除了该文件。 然后我通过命令行重新创build文件。

干杯!

我错过了一些事情来下载我的私人存储库中发布的软件包。

首先文件名是.npmrc.txt而不是.npmrc 。 在Windows中,您不能直接创build文件名。 所以我打开命令提示符然后解雇

 echo "auth_token" > .npmrc 

其次,我只是在.npmrc文件中粘贴我的auth_token 。 您还必须追加registry地址。

 //**.**.visualstudio.com/_packaging/**/npm/registry/:_authToken=token_here