npm link issue related to Homebrew

Viewed 105

So I'm trying to use npm link to make some binaries available globally as CLI commands.

My package.json looks like this:

{
  "bin": {
    "foo": "./relative/path/to/foo",
  },
  ...

When I run npm link, I get the following error:

npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /opt/homebrew/lib/node_modules/foo/relative/path/to/foo
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/opt/homebrew/lib/node_modules/foo/relative/path/to/foo'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

So it seems it's tryiung to link the file from a homebrew install directory for some reason.

I've tried re-installing npm from the installer at nodejs.org, but it seems like npm is still coming from homebrew for some reason:

% which node
/usr/local/bin/node
% which npm
/opt/homebrew/bin/npm

But there does not seem to be a brew formula for npm. Where is this homebrew npm coming from and how do I get rid of it?

1 Answers
rm -rf /opt/homebrew/bin/npm

The above did the trick for me after uninstalling node with brew and then re-installing with nvm (without brew).

Related