Errors with Netlify CLI

I’m trying to deploy a React app and when I enter npm install netlify-cli -g, I get this error message:

npm WARN deprecated object-keys@0.2.0: Please update to the latest object-keys
    npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @netlify/traffic-mesh-agent-linux-x64@^0.26.0 (node_modules/netlify-cli/node_modules/@netlify/traffic-mesh-agent/node_modules/@netlify/traffic-mesh-agent-linux-x64):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @netlify/traffic-mesh-agent-linux-x64@0.26.0: wanted {"os":"linux","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @netlify/traffic-mesh-agent-win32-x64@^0.26.0 (node_modules/netlify-cli/node_modules/@netlify/traffic-mesh-agent/node_modules/@netlify/traffic-mesh-agent-win32-x64):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @netlify/traffic-mesh-agent-win32-x64@0.26.0: wanted {"os":"win32","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
    npm WARN @octokit/plugin-request-log@1.0.2 requires a peer of @octokit/core@>=3 but none is installed. You must install peer dependencies yourself.

    npm ERR! code EACCES
    npm ERR! syscall access
    npm ERR! path /usr/local/lib/node_modules
    npm ERR! errno -13
    npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
    npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
    npm ERR!   errno: -13,
    npm ERR!   code: 'EACCES',
    npm ERR!   syscall: 'access',
    npm ERR!   path: '/usr/local/lib/node_modules'
    npm ERR! }
    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.

According to the error, your user doesn’t have permissions to write to the directory you’re trying. It even says to try as an administrator or root. Have you tried that? If you can’t access root, try installing to a different folder.

It’s my computer, I should be the admin, but how would I switch to either that or the root?

Depends on your OS. I take it you’re using macOS. You should be typing sudo <enter> your (computer) account password. It should be the same for any Linux distribution too.

That I am. I entered sudo but only got a bunch of ways to use it.

I didn’t quite get you. Could you please rephrase it?

usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command]
usage: sudo [-AbEHknPS] [-C num] [-g group] [-h host] [-p prompt] [-T timeout] [-u user] [VAR=value] [-i|-s]
[]
usage: sudo -e [-AknS] [-C num] [-g group] [-h host] [-p prompt] [-T timeout] [-u user] file …

That was what I got

Oh, in that sense. Well, run sudo npm install netlify-cli -g. That would ask for the password.

1 Like

That worked! Thanks for the help.

1 Like