npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Silent npm WARN cannot run in wd during prepareGitDep


What I Wanted to Do

npm install => if success all dependencies specified in package.json are available in node_modules. Even github dependencies. If not successful, an error for what did go wrong

What Happened Instead

some files in github dependencies were missing. thus causing failure in the next steps.
Using the -ddd option, a warning was output: WARN cannot run in wd

Reproduction Steps

In my case,

docker run -it node:10.16.0-alpine /bin/sh

inside the container run apk add git
npm install gatsby-plugin-remote-images@graysonhicks/gatsby-plugin-remote-images

missing supposed files to be built in node_modules/gatsby-plugin-remote-images/ particularly gatsby-node.js

Thus the gatsby build failing.


After investigation it seems that it is due:
If npm was invoked with root privileges, then it will change the uid to the user account or uid specified by the user config, which defaults to nobody . Set the unsafe-perm flag to run scripts with root privileges.

Nonetheless, the npm install was silently incorrect and returning a 0 exit code, thus hard to find the issue without the -ddd flag.

Platform Info

Docker image

npm --versions { npm: '6.9.0', ares: '1.15.0', brotli: '1.0.7', cldr: '35.1', http_parser: '2.8.0', icu: '64.2', modules: '64', napi: '4', nghttp2: '1.34.0', node: '10.16.0', openssl: '1.1.1b', tz: '2019a', unicode: '12.1', uv: '1.28.0', v8: '', zlib: '1.2.11' } node -p process.platform