无法设置本地npm repo

时间:2018-04-07 17:49:38

标签: npm npmjs

我写了一个库,我想测试人们可以从npm导入它并按预期使用它。为此我设置了一个像

这样的本地NPM回购
npm install -g local-npm
npm set registry http://127.0.0.1:5080
local-npm

这在我的计算机上启动了一个本地存储库。现在我去了我的图书馆项目,我做了

npm publish

但是我收到了错误

npm ERR! code ENEEDAUTH
npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`

我做了

npm adduser

但是我收到了错误

npm adduser
Username: foo
Password:
Email: (this IS public) foo@bar.com
npm ERR! code EAUTHIP
npm ERR! Unable to authenticate, need: Basic

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/.npm/_logs/2018-04-07T17_46_18_631Z-debug.log

对于这个本地回购。我不想要任何用户等,因为这仅用于测试。我希望能够在没有任何凭据或用户的情况下直接发布到此。那可能吗?

另外,另一个问题是,现在我已经设置了本地npm并且在我的项目中执行npm i react -D安装将失败,因为此存储库不包含反应。那么当有人npm i react -D它仍然进入原始的NPM存储库时,它仍然可以进入原始的NPM存储库,只有当它npm i foo-lib -D时它才会作为后备来到我的存储库,因为原始的npm存储库不包含我的foo-lib它只发布到这个本地存储库。

编辑:我尝试了npm publish --registry http://127.0.0.1:5800,我收到了以下错误

0/bin/npm" "publish" "--registry" "http://127.0.0.1:5080"
23 verbose node v9.5.0
24 verbose npm  v5.7.1
25 error code ENEEDAUTH
26 error need auth auth required for publishing
27 error need auth You need to authorize this machine using `npm adduser`
28 verbose exit [ 1, true ]

所以它不会让我创建一个用户,它不会让我在没有用户的情况下发布。

Edit2 ::我也尝试了另一种方式。

服务器启动时首先运行local-npm

从另一个窗口做

npm set registry http://127.0.0.1:5080
npm publish --registry http://127.0.0.1:5080
npm publish

一切都会导致

~/IdeaProjects/t > npm publish --registry http://127.0.0.1:5080
npm ERR! code ENEEDAUTH
npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users//.npm/_logs/2018-04-07T18_32_53_815Z-debug.log
~/IdeaProjects/t > npm adduser
Username: foo
Password:
Email: (this IS public) foo@bar.com
npm ERR! code EAUTHIP
npm ERR! Unable to authenticate, need: Basic

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users//.npm/_logs/2018-04-07T18_33_25_737Z-debug.log    

文件内容

19 verbose argv "/Users/a/.nvm/versions/node/v9.5.0/bin/node" "/Users/a/.nvm/versions/node/v9.5.0/bin/npm" "adduser"
20 verbose node v9.5.0
21 verbose npm  v5.7.1
22 error code EAUTHIP
23 error Unable to authenticate, need: Basic

1 个答案:

答案 0 :(得分:1)

试试这个:

npm publish --registry http://127.0.0.1:5080

https://docs.npmjs.com/misc/registry#can-i-run-my-own-private-registry