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.

Set NPM Auth Token?

See original GitHub issue

I’m new to CircleCI, and I’m trying to use the Cypress CircleCI Orb. To build my application, I need to install private NPM packages (using Yarn). So I need to be able to run a command like this somewhere in config.yml:

echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc

I don’t know where to put it though. The install job’s build parameter runs after yarn install. Is it possible to set the NPM auth token somewhere? Maybe @eddiewebb would have a suggestion? I think one approach would be to add a parameter called pre to the install job.

Alternatively, I’d imagine I could write out my config.yml with all the settings I need (except for the NPM token). Then, I could “eject” using circleci config process config.yml and figure out where to add the NPM auth token.

Side Note

This Orb seems really cool! We’ve been using the Cypress Dashboard and Travis CI to run our Cypress tests in CI for the past several months. We never found a way to avoid installing Cypress on every machine when running the tests in parallel. That introduces a huge bottleneck. We could run our test suite so much more efficiently with this orb!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
eddiewebbcommented, Jan 13, 2019

@nmchaves, all orb jobs have a built in pre-steps and post-steps

The first could be used in your call to the test job to run and commands to want to occur before Cypress steps

version: 2.1
orbs:
  cypress: cypress-io/cypress@1.4.0
workflows:
  build:
    jobs:
      - cypress/run:
          yarn: true
          pre-steps: 
            - run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc

2reactions
bahmutovcommented, Jan 14, 2019

@nmchaves I would always strive to avoid duplicate work. So I would install NPM dependencies and build the server in the cypress/install job, then it will attach the workspace and pass everything into cypress/run jobs (which can run in parallel). The example https://github.com/cypress-io/circleci-orb/blob/master/docs/examples.md#build-app shows this

But you can also just look at the effective config, either on CircleCI web application or using CLI command https://github.com/cypress-io/circleci-orb#effective-config to see what exactly is going on.

To close this issue I will add an example of setting NPM auth token using pre- job step like @eddiewebb has shown to the documentation, it is a good one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using private packages in a CI/CD workflow - npm Docs
Create a new access token · Set the token as an environment variable on the CI/CD server · Create and check in a...
Read more >
About access tokens - npm Docs
An access token is an alternative to using your username and password for authenticating to npm when using the API or the npm...
Read more >
npm-token
npm token list : Shows a table of all active authentication tokens. You can request this as JSON with --json or tab-separated values...
Read more >
Globally configure NPM with a token registry to a specific ...
But what I want is a combinaison of the two methods: Using the token at when assigning the registry URL to my scope....
Read more >
Working with the npm registry - GitHub Docs
You can authenticate to GitHub Packages with npm by either editing your per-user ~/.npmrc file to include your personal access token (classic) or...
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