If you want to install package from some registry, set the registry first
# choose one of the following if you don't have a .npmrc file
npm config set @crosscopy:registry https://registry.npmjs.org
npm config set @crosscopy:registry https://npm.pkg.github.com
# publish to npmjs registry
npm config set @crosscopy:registry https://registry.npmjs.org
npm publish --access public
# publish to github registry
npm config set @crosscopy:registry https://npm.pkg.github.com
npm publish
Create a .npmrc
file also works, but then it seems to have the highest priority, doesn't work if you want to publish to multiple registry.
.npmrc
should have something like the following the set the registry for a specific scope.
@crosscopy:registry=https://npm.pkg.github.com
You can add the following scripts in package.json
's scripts
"install:github": "npm config set @crosscopy:registry https://npm.pkg.github.com && npm i",
"publish:github": "npm config set @crosscopy:registry https://npm.pkg.github.com && npm publish",
"publish:npmjs": "npm config set @crosscopy:registry https://registry.npmjs.org && npm publish"