I wrote a library and I want to test that people can import it from npm and use it as expected. Towards this I set up a local NPM repo like
npm install -g local-npm
npm set registry http://127.0.0.1:5080
local-npm
This started a local repository on my computer. Now I went to my library project and I did
npm publish
but I get an error
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`
I did
npm adduser
but I get an error
npm adduser
Username: foo
Password:
Email: (this IS public) [email protected]
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
For this local repo. I don't want any users etc because this is only for testing. I want to be able to straight publish to this without any credentials or users. is that possible?
Also, another question is that now that I have setup a local npm and I do a npm i react -D
in my project the installation would fail because this repository doesn't contain react. So is it possible that when someone does npm i react -D
it still goes to the original NPM repository when when I do npm i foo-lib -D
only then it comes to my repository as a fallback because the original npm repository doesn't contain my foo-lib it was only published to this local repository.
Edit: I tried npm publish --registry http://127.0.0.1:5800
and I got the following error
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 ]
So it won't let me create a user and it won't let me publish without a user.
Edit2:: I tried the other way round as well.
First run local-npm
now when the server starts up
from another window do
npm set registry http://127.0.0.1:5080
npm publish --registry http://127.0.0.1:5080
npm publish
everything results in
~/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) [email protected]
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
file contents
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
Try this:
https://docs.npmjs.com/misc/registry#can-i-run-my-own-private-registry