Skip to content

Error "No user .npmrc file found" when file actually exists #342

Description

@MikelArnaiz

I'm getting a 403 when trying to release a private page to the private Github registry.
The project is a fresh turbo project created with yarn dlx create-turbo@latest and a dummy foo package to test the release works.

The logs says the .npmrc file doesn't exist, but it does:

auto-install-peers = true
@myorg:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}

My release workflow includes:

- name: Create Release Pull Request or Publish to npm
  id: changesets
  uses: changesets/action@v1
  with:
    version: yarn run changeset:version # translated as changeset version && yarn install --mode=update-lockfile
    publish: yarn run release-packages # translated as turbo run build --filter='./packages/*' && changeset publish
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Token automatically added by Github

Error output, note the No user .npmrc file found, creating one line.

Run changesets/action@v1
  with:
    version: yarn run changeset:version
    publish: yarn run release-packages
    setupGitUser: true
    createGithubReleases: true
  env:
    YARN_VERSION: 4.0.2
    GITHUB_TOKEN: ***
setting git user
/usr/bin/git config user.name "github-actions[bot]"
/usr/bin/git config user.email "github-actions[bot]@users.noreply.github.com"
setting GitHub credentials
No changesets found, attempting to publish any unpublished packages to npm
No user .npmrc file found, creating one
/usr/local/bin/yarn run release-packages
• Packages in scope: @myorg/foo, @repo/eslint-config, @repo/typescript-config, @repo/ui
• Running build in 4 packages
• Remote caching disabled

No tasks were executed as part of this run.

 Tasks:    0 successful, 0 total
Cached:    0 cached, 0 total
  Time:    131ms 

🦋  info npm info @myorg/foo
🦋  error Received an unknown error code: E403 for npm info "@myorg/foo"
🦋  error 403 Forbidden - GET https://npm.pkg.github.com/@myorg%2ffoo - Permission permission_denied: read_package
🦋  error In most cases, you or one of your dependencies are requesting
🦋  error a package version that is forbidden by your security policy, or
🦋  error on a server you do not have access to.
Error: Error: The process '/usr/local/bin/yarn' failed with exit code 1
Error: The process '/usr/local/bin/yarn' failed with exit code 1

I've tracked the error to the source code, it's coming from this conditional, on the else block:

action/src/index.ts

Lines 58 to 59 in 2bb9bcb

let userNpmrcPath = `${process.env.HOME}/.npmrc`;
if (fs.existsSync(userNpmrcPath)) {

I had changesets working for another turborepo monorepo with the only notably difference that it was using pnpm.
What is going wrong? perhaps process.env.HOME, but why?

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