npm not recognizing config


(William) #1

I’m installing packages via Salt using npm 5.10 and its npm package provider. I’m dropping down /root/.npmrc right before installing some packages.

          //registry.npmjs.org/:_authToken=xxxxxx 
          progress=false
          unsafe-perm=true  # Without this, it's slooooooooooow because of npm-gyp permissions stuff

This config works locally as root if I run npm info [private package] or npm whoami
However, on the first run, npm doesn’t seem to realize it’s authenticated. If I have it cat the file above as a debugging command during the run, it definitely exists, but then npm info [private package] or npm whoami
act as if it’s not authenticated.

Additionally, if I do a subsequent salt run, the private packages get installed.
Is there something I can do to make sure it sees the npm config? I already made sure that cwd and HOME env vars are set to /root.


(William) #2

Hrm - seems to be an issue with the output or return code from the first run - after I set cwd / HOME for those commands, they run as expected too. In our test setup, they’re running via sudo with environment preserved, which I think is part of the problem.


(William) #3

The actual issue seems to have been this… the Salt module for npm is not identifying the json output in an ideal way… I think I have a fix for that…

That said, I wonder if a) the [grpc] Success... type output should be showing up in this case, and also whether it should be going to stdout vs. stderr?

Currently, both the json output and the message are going to stderr.

root@16b37a02a7bc:~# npm install --json --silent --global '@google-cloud/monitoring@^0.4.1' 
[grpc] Success: "/usr/lib/node_modules/@google-cloud/monitoring/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node" is installed via remote
{
  "added": [
    {
      "action": "add",
      "name": "@protobufjs/aspromise",
      "version": "1.1.2",
      "path": "/usr/lib/node_modules/@google-cloud/monitoring/node_modules/@protobufjs/aspromise"
    },

(system) #4

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.