Following npm docs failing to authenticate

darrell.tunnell's Avatar

darrell.tunnell

30 Sep, 2018 12:11 PM

I am following these docs in order to try and publish an `npm` package to npmjs: https://www.appveyor.com/docs/lang/nodejs-iojs/
Here is my build: https://ci.appveyor.com/project/dazinator/netpack-typescript

The problem is, here is my appveyor.yml:

```
environment:
  nodejs_version: 6
  npm_authtoken:
    secure: ZFDpQDP37rVIg8if7QBpgVgCYhEtuaB6k/7Kd5VdZf5X9Eyi3wtdBZxnYLPpIVnH
build: off

install:
- ps: Install-Product node $env:nodejs_version
- ps: npm install --loglevel=error
- ps: '"//registry.npmjs.org/:_authToken=$env:npm_authtoken`n" | out-file "$env:userprofile\.npmrc" -Encoding ASCII'
- ps: npm whoami

deploy_script:
- ps: npm publish
```

As you can see from the build it fails at the `whoami` step: https://ci.appveyor.com/project/dazinator/netpack-typescript#L205
For some reason, even though I am creating the `$env:userprofile\.npmrc` file, it doesn't appear to be picked up and used to authenticate with..

Any ideas?

  1. 1 Posted by darrell.tunnell on 30 Sep, 2018 12:18 PM

    darrell.tunnell's Avatar

    Hmm for some reason, I didn't make any changes to my appveyor.yml file, but I made some changes on web appveyor project, and it seems to now be working. Perhaps some envrionment variable settings on the web were overriding what was in my appveyor.yml file - although I would have thought it would work the other way around..

  2. Support Staff 2 Posted by Ilya Finkelshte... on 01 Oct, 2018 02:40 AM

    Ilya Finkelshteyn's Avatar

    I would call all npm commands from cmd, not ps, e.g. - cmd: npm whoami or simple - npm whoami (assuming you are running Windows build on AppVeyor).

    Problem is that npm often writes standard output to stdErrwhich AppVeyor custom PowerShell host treats as error.

  3. Ilya Finkelshteyn closed this discussion on 01 Oct, 2018 02:48 AM.

  4. Ilya Finkelshteyn re-opened this discussion on 01 Oct, 2018 02:48 AM

  5. Ilya Finkelshteyn closed this discussion on 01 Dec, 2018 09:00 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

22 Aug, 2019 08:13 PM
21 Aug, 2019 11:06 PM
21 Aug, 2019 02:08 PM
21 Aug, 2019 01:37 PM
21 Aug, 2019 10:21 AM
21 Aug, 2019 05:56 AM