Alex's Slip-box

These are my org-mode notes in sort of Zettelkasten style

npm install and permissions

# The problem

While working on the CI script for notes.alex-mille.co, I ran into a permissions problem when installing the netlify-cli.

sudo npm install netlify-cli -g
> esbuild@0.11.18 postinstall /usr/local/lib/node_modules/netlify-cli/node_modules/esbuild
> node install.js

Trying to install "esbuild-linux-64" using npm
Failed to install "esbuild-linux-64" using npm: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/netlify-cli/node_modules/esbuild/esbuild-pwn6zf0scfg'
Trying to download "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.11.18.tgz"
/usr/local/lib/node_modules/netlify-cli/node_modules/esbuild/install.js:195
      throw e;
      ^

Error: EACCES: permission denied, open '/usr/local/lib/node_modules/netlify-cli/node_modules/esbuild/bin/esbuild__'
    at Object.openSync (fs.js:476:3)
    at Object.writeFileSync (fs.js:1467:35)
    at installBinaryFromPackage (/usr/local/lib/node_modules/netlify-cli/node_modules/esbuild/install.js:58:6)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  errno: -13,
  syscall: 'open',
  code: 'EACCES',
  path: '/usr/local/lib/node_modules/netlify-cli/node_modules/esbuild/bin/esbuild__'
}

So it looks like the error is being thrown from a postinstall script for esbuild.

# The solution

Make the npm scripts run in the same context as the originally command (ie, no user switching). To do this use the --unsafe-perm flag.

sudo npm install netlify-cli -g --unsafe-perm=true

See these posts for more details:

Search Results