MacOS BigSur - netlify-cli installed locally but not found

Hi,

I’m using nuxtjs to make a static site and Netlify to host it.

I can install netlify-cli locally but the command is not found:

% npm install netlify-cli --save-dev

> netlify-cli@3.30.1 postinstall /Users/username/projectname/node_modules/netlify-cli
> node ./scripts/postinstall.js
Success! Netlify CLI has been installed!

There are a few warnings though that seems just to skip optional dependencies:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @netlify/traffic-mesh-agent-linux-x64@0.27.10 (node_modules/netlify-cli/node_modules/@netlify/traffic-mesh-agent-linux-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @netlify/traffic-mesh-agent-linux-x64@0.27.10: wanted {"os":"linux","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @netlify/traffic-mesh-agent-win32-x64@0.27.10 (node_modules/netlify-cli/node_modules/@netlify/traffic-mesh-agent-win32-x64):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @netlify/traffic-mesh-agent-win32-x64@0.27.10: wanted {"os":"win32","arch":"x64"} (current: {"os":"darwin","arch":"x64"})
  • there are quite a few vulnerabilities. As it is my first time, is it serious?

found 233 vulnerabilities (231 moderate, 2 high)

The problem is now that the netlify command is not found, although it’s in my dev dependencies, in the node modules… Everything seems just fine.

I also had problems for the global installation, but I could resolve this using this tip: https://dev.to/kobyo/how-to-solve-netfliy-command-not-found-problem-g3c So the netlify-cli is indeed installed globally.

But I fail to understand how this could influence a local installation and how I can resolve this.

If someone can help, that would be nice. Thanks.

Update: it works if in zsh I use:

$(npm bin)/netlify

But why can’t I just simplu use netlify ?

Hi @jeromesson welcome to the Netlify community :netliconfetti:

You’re running netlify-cli as a local module, and not installing it globally via npm i -g netlify-cli? I’m running BigSur and have no issues with having it installed globally. With it installed such I can run netlify <command> from anywhere.

I’m not sure why your install is showing such a high number of vulnerabilities. I might have a few which is generally fixed with npm audit fix.

Hi, thanks for your answer.

I have no problem anymore to install it globally but that’s not what I want. Netlify recommends a local installation with --save-dev . Doing so, this particular project will not be impacted if a major change to the CLI occurs. That could break your project.

The weird thing is that the local instal works, and the netlify-cli is there. I just cannot invoke it by just typing netlify <command>, I need to tell where it is like in $(npm bin)/netlify <command>

The executable should be found without me telling where it is, at least it’s what I understand. Or maybe I’m wrong?

hi @jeromesson , would you mind looking through the issues here and filing a new one if nothing existing matches your use case? thanks!

1 Like

Using $(npm bin)/netlify <command> is the standard way of running local npm packages as I understand (e.g. Run Locally Installed NPM Packages Without Global Install :: rockyourcode).

I should add that this is not something I do with my projects. I have netlify-cli and many other tools installed globally not locally.

Hi, thanks for the info. I actually found something similar, although on Windows: Issue 1088

From it I understand that I have to run npm run netlify <command> instead of just netlify <command> (+ add the script in package.json).

I really though that was not necessary to add npm run to it, but if it is what I need to do to make it work, no big deal. I’d really line to be sure though.

Thanks again.

Thanks again, yes it works. As mentionned in my previous reply, you can also add a script in the package.json and use npm run netlify.

The script is kind of obvious:

"scripts": {
    "netlify": "netlify"
  },

Just easier to remember I think.

Now globally vs locally, I don’t know. I always fear that one day a global update will break everything in my projects. But maybe that’s unjustified.