question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.npmrc is not created

See original GitHub issue

Expected

When registry-url input is set with env.NODE_AUTH_TOKEN an .npmrc file should be created in project root.

Actual

When registry-url input is set with env.NODE_AUTH_TOKEN an .npmrc file is not created.

Reproduction

.github/workflows/publish.yml

name: Publish
on:
  push:
    branches:
      - master

jobs:
  publish:
    runs-on: ubuntu-latest
    env:
      NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
    steps:
      - uses: actions/checkout@v2
      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: '12.x'
          registry-url: 'https://registry.npmjs.org'
          scope: '@foo-software'
      - name: Publish Packages
        run: |
          cat .npmrc

package.json

{
  "name": "root",
  "private": true,
  "keywords": [
    ...
  ],
  "scripts": {
    ...
  },
  "husky": {
    ...
  },
  "lint-staged": {
    ...
  },
  "devDependencies": {
    ...
  }
}

Note: My project is a Lerna based monorepo, so the above package.json has minimal fields. Perhaps, this functionality requires certain fields / values, but I’m not sure why and what those fields would be.

GitHub Action output and linked here.

Screen Shot 2021-03-31 at 11 03 29 PM

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:14

github_iconTop GitHub Comments

9reactions
adamhensoncommented, Apr 1, 2021

For anyone who’s come across this, my workaround is below, but it feels like a hack since this functionality supposedly exists in actions/setup-node.

      - name: Publish Packages
        run: |
+         echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN  }}' > ${{ github.workspace }}/.npmrc
          cat .npmrc
5reactions
adamhensoncommented, May 19, 2021

Please stop adding comments that are not helpful in resolving this issue. For now I’m just using my workaround. I’m thinking about closing this since it hasn’t gotten attention from actual contributors. I’m simply reporting a feature of this project that is broken.

My use case isn’t very relevant, but since people have been inquiring and for context: it is simple and standard - I have a repo that includes the code for packages to be published to NPM. I’m using actions/setup_node to setup the Node.js environment which includes NPM and authorizing NPM.

The README for this project states that it can be used for configuring authentication for GPR or npm.

In the usage section of the README it provides an example that you might use to setup and environment to publish packages for NPM. See Publish to npmjs and GPR with npm example.

This is the example from the README.

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
  with:
    node-version: '10.x'
    registry-url: <registry url>
- run: yarn install
- run: yarn publish
  env:
    NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
- uses: actions/setup-node@v2
  with:
    registry-url: 'https://npm.pkg.github.com'
- run: yarn publish
  env:
    NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

And this setup isn’t actually working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot locate .npmrc file after installing nodejs and npm on ...
My question is I am not able to locate .npmrc file. Is n't it weird. I want to know is it created by...
Read more >
generate .npmrc file is not working properly
the generate npmrc file for Artifacts is not actually creating the tokenized string appropriately. I am unable to connect successfully with ...
Read more >
Ubuntu Manpage: npmrc - The npm config files
The npm config command can be used to update and edit the contents of the user ... Additionally, this file is not read...
Read more >
The Ultimate Guide to Configuring NPM - Stack Abuse
npmrc Files. npm allows you to use a few different rc files, much like ~/.bashrc , to set your configurations. The four locations...
Read more >
config | npm Docs
Run npm config ls -l to see a set of configuration parameters that are internal to npm, ... Setting this to false results...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found