-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Hi team! I've just spent the last 3 days trying to make Projen's use of publib work, and I found the magic sauce this morning .. but no where in this project or projen is this well documented. (See AWS Support Case ID 174835671800811 for some of our troubleshooting steps).
The problem we ran into was the following error:
NPM_DIST_TAG=latest NPM_REGISTRY=https://...-....d.codeartifact.us-west-2.amazonaws.com/npm/myrepo npx -p publib@latest publib-npm
(node:17081) ExperimentalWarning: Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
npm notice
npm notice Tarball Contents
npm notice 3.3kB .eslintrc.yml
npm notice 93.2kB .jsii
npm notice 1.2MB API.md..
...
npm error code ENEEDAUTH
npm error need auth This command requires you to be logged in to https://...-....d.codeartifact.us-west-2.amazonaws.com/npm/myrepo
npm error need auth You need to authorize this machine using `npm adduser`
npm error A complete log of this run can be found in: /Users/diranged/.npm/_logs/2025-05-27T15_20_03_599Z-debug-0.log
After a bunch of troubleshooting, we realized we had to make sure multiple settings were in-place and these just aren't well documented.
- The
package.jsonneedsname: @<scope>/<package>to be set - you cannot just havename: <package>. - The
package.jsonneedspublishConfig.registryset (which mimics passing in--registry ...to thenpm publishcommand) - The
publishConfig.registryvalue MUST end in a/... for example:
a. INVALID:https://...-....d.codeartifact.us-west-2.amazonaws.com/npm/myrepo
b. VALID:https://...-....d.codeartifact.us-west-2.amazonaws.com/npm/myrepo/
The last piece (3) was the most critical because without it the npm publish fails in this really confusing error that sure looks like it should be already logged into the right repository - but it doesn't quite match because of the missing trailing /
I'd really like to see the documentation improved here because this was a subtle but painful process to figure out.