Unable to install Netlify-Cli

2.3k views Asked by At

i was trying to install Netlify-Cli using Linux Terminal.
I tried this command:

npm install netlify-cli -g

But it is throwing some error

> [email protected] preinstall /usr/local/lib/node_modules/netlify-cli/node_modules/yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/netlify-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @netlify/[email protected] (node_modules/netlify-cli/node_modules/@netlify/traffic-mesh-agent-win32-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @netlify/[email protected]: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @netlify/[email protected] (node_modules/netlify-cli/node_modules/@netlify/traffic-mesh-agent-darwin-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @netlify/[email protected]: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})

npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/netlify-cli/bin/run
npm ERR! dest /usr/local/bin/netlify
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/netlify-cli/bin/run' -> '/usr/local/bin/netlify'
npm ERR!  { [Error: EACCES: permission denied, symlink '../lib/node_modules/netlify-cli/bin/run' -> '/usr/local/bin/netlify']
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, symlink '../lib/node_modules/netlify-cli/bin/run' -> '/usr/local/bin/netlify'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'symlink',
npm ERR!      path: '../lib/node_modules/netlify-cli/bin/run',
npm ERR!      dest: '/usr/local/bin/netlify' },
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, symlink \'../lib/node_modules/netlify-cli/bin/run\' -> \'/usr/local/bin/netlify\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../lib/node_modules/netlify-cli/bin/run',
npm ERR!   dest: '/usr/local/bin/netlify' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/silence/.npm/_logs/2021-05-09T13_28_21_198Z-debug.log

If any small help would be helpful.

2

There are 2 answers

0
Silence On BEST ANSWER

Thanks to boirslav popov.
As he mentioned in his answer it has worked for some of them ie,

sudo npm install netlify-cli -g

But sadly it didn't work for me :(

For those, if the above command didn't work can follow the attached answer :D Answer

I followed this answer

i.e,

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

0
chillcoder On

Im using a Mac.

So I actually had to go into my library folder and manually delete the netlify folder.

I then reinstalled the netlify cli via brew:

brew reinstall netlify-cli

This way you dont get all the permissions errors. In general this is seems like the best way to do things on mac when dealing with a cli.

It would be good to know why Mac gets mad at just using the global npm install tho.