Skip to content

Docs: Please improve the Codeartifact instructions around the package.json requirements #1675

@diranged

Description

@diranged

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.

  1. The package.json needs name: @<scope>/<package> to be set - you cannot just have name: <package>.
  2. The package.json needs publishConfig.registry set (which mimics passing in --registry ... to the npm publish command)
  3. The publishConfig.registry value 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions