DEV Community

loading...

sh: 1: node: Permission denied on `volta install`

michalbryxi profile image Michal Bryxí ・3 min read

Earlier this week I started seeing failures on my Docker builds with a rather cryptic message: sh: 1: node: Permission denied. This was really strange, because I did not change anything significant enough to cause this error. Example of failing logs:

For netlify-cli:

Step 17/18 : RUN volta install netlify-cli --verbose
 ---> Running in 53c120c8aebb
[verbose] Acquiring lock on Volta directory: /root/.volta/volta.lock
[verbose] Found default configuration at '/root/.volta/tools/user/platform.json'
[verbose] node@12.19.0 has already been fetched, skipping download
[verbose] yarn@1.22.10 has already been fetched, skipping download
[verbose] Installing netlify-cli with command: "npm" "install" "--global" "--loglevel=warn" "--no-update-notifier" "--no-audit" "netlify-cli"
[verbose] [install stderr]
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated object-keys@0.2.0: Please update to the latest object-keys
sh: 1: node: Permission denied
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/netlify-cli/node_modules/rollup/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN @octokit/plugin-request-log@1.0.1 requires a peer of @octokit/core@>=3 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! netlify-cli@2.65.7 postinstall: `node ./scripts/postinstall.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the netlify-cli@2.65.7 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Enter fullscreen mode Exit fullscreen mode

For ember-cli:

Step 17/18 : RUN volta install ember-cli netlify-cli --verbose
 ---> Running in c09e5ec1b6cf
[verbose] Acquiring lock on Volta directory: /root/.volta/volta.lock
[verbose] Found default configuration at '/root/.volta/tools/user/platform.json'
[verbose] node@12.19.0 has already been fetched, skipping download
[verbose] yarn@1.22.10 has already been fetched, skipping download
[verbose] Installing ember-cli with command: "npm" "install" "--global" "--loglevel=warn" "--no-update-notifier" "--no-audit" "ember-cli"
[verbose] [install stderr]
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
sh: 1: node: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! core-js@2.6.11 postinstall: `node -e "try{require('./postinstall')}catch(e){}"`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the core-js@2.6.11 postinstall script.
Enter fullscreen mode Exit fullscreen mode

The error message looks slightly different in each case.

What I think is the problem: In my Docker container, I'm using Volta for node/yarn version management. And for the volta install command it internally uses npm install --global, which does not like to run when the script is executed as root.

So the solution was to add following line to my Dockerfile just before the volta install command:

RUN npm set unsafe-perm true
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide