Netlify: command not found in Zsh

Hello,

I am getting the following message when trying to run npm install -g netlify-cli.

npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
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 source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.

added 1359 packages in 47s

180 packages are looking for funding
  run `npm fund` for details

When I type netlify command it gives me netlify: command not found error

Please help.

Is the path where netlify (and other globally installed node packages) in the $PATH variable in the shell?

Try

% whereis netlify
netlify: /usr/local/bin/netlify

(this is an example.)

Then check $PATH (based on the above example path)

% echo $PATH | grep --color=always '/usr/local/bin'
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

(your results will vary to the above.)

When I tried type

whereis netlify

I am getting the following response:

netlify:

What’s that suppose to mean?

That the system cannot find it. Quite possibly because it doesn’t exist (isn’t installed) or possibly because the location isn’t indexed.

I have installed as a test.

% npm install -g netlify-cli
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
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 source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.

added 1359 packages in 26s

180 packages are looking for funding
  run `npm fund` for details

Then run

% whereis netlify
netlify: /usr/local/bin/netlify

You can check which npm packages are globally installed using

% npm list -g
usr/local/lib
β”œβ”€β”€ @gridsome/cli@0.3.4
β”œβ”€β”€ chalk@4.1.2
β”œβ”€β”€ corepack@0.17.0
β”œβ”€β”€ http-server@14.1.1
β”œβ”€β”€ lambda-local@2.0.0
β”œβ”€β”€ netlify-cli@15.0.0
β”œβ”€β”€ npm-run-all@4.1.5
β”œβ”€β”€ npm@9.5.1
β”œβ”€β”€ serve@14.2.0
└── yarn@1.22.19

(the above is an example.)

Hello @jasiqli I don’t get what do you mean by that.

Here is the output when I run npm list -g

/usr/local/Cellar/node/20.1.0/lib
β”œβ”€β”€ netlify-cli@15.0.0
└── npm@9.6.6

That shows that netlify-cli is installed. However, the location is different because you used Brew to install node instead of the office pacakge from the node website.

If you have only just installed node you may need to restart the terminal for the $PATH to update.

I cannot remember if brew automatically appends the /path/to/node and the Node modules directory to $PATH (haven’t used it in some time) or whether you need to append it manually (think the former, but…)

I got it fixed now.

It appears that I need to run brew unlink node and brew link node to perform symlink in my system.

Cheers

1 Like