npm link issue related to Homebrew - npm

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?

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

i get error when i run sudo npm run serve

I was getting error when i was installing npm but it seemed to me that it run fine. I created default app and i tried sudo npm run serve but i get this error
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/00/00/00/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/00/00/00/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
I tried:`npm cache clear` & `sudo npm cache clear` and i get error starting with As of npm#5, the npm cache self-heals from corruption issues.
NPM VERSION 8.18.0
Fixed it, i needed to add package.json file to my app.

Trying to update to latest NPM version but existence of npx is blocking it

I would like to update to the latest npm version on a mac, so of course I ran
npm install -g npm#latest
but I got the following error message
rm not removing /usr/local/bin/npm as it wasn't installed by /usr/local/lib/node_modules/npm
npm WARN rm not removing /usr/local/bin/npx as it wasn't installed by /usr/local/lib/node_modules/npm
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/npm/bin/npx-cli.js
npm ERR! dest /usr/local/bin/npx
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/npm/bin/npx-cli.js' -> '/usr/local/bin/npx'
npm ERR! File exists: /usr/local/bin/npx
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
Ok, I would like to not run --force to overwrite files recklessly - so how do I get npm to install the latest version in this case?

NPM completely broken and won't reinstall after failed upgrade

Mac Catalina 10.15.6
I already had npm installed. I wanted to upgrade so I ran the following.
npm install -g npm
Below is the output:
$name#$names-MacBook-Pro desktop % npm install -g npm
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm ERR! code EEXIST npm ERR! syscall symlink npm ERR! path
../../../lib/node_modules/npm/man/man1/npm-bin.1 npm ERR! dest
/usr/local/share/man/man1/npm-bin.1 npm ERR! errno -17 npm ERR!
EEXIST: file already exists, symlink
'../../../lib/node_modules/npm/man/man1/npm-bin.1' ->
'/usr/local/share/man/man1/npm-bin.1' npm ERR! File exists:
/usr/local/share/man/man1/npm-bin.1 npm ERR! Remove the existing file
and try again, or run npm npm ERR! with --force to overwrite files
recklessly.
npm ERR! A complete log of this run can be found in: npm ERR!
/Users/$name/.npm/_logs/2020-10-04T14_41_02_611Z-debug.log
Now all NPM commands fail.
zsh: command not found: npm
Everything from:
npm -v
sudo npm install npm -g
I just used home brew to upgrade NPM and it deleted and reinstalled all the necessary files.
This generally works for me on Mac:
brew upgrade
brew cleanup
brew install npm
(note you'll need the xcode tools if you don't have it - try xcode-select --install or check out this answer.)
Now, try npm install again and see if that changes anything.
Also, see this potentially related answer.

npm install fail -- error message: enoent ENOENT: no such file or directory

i'm building an Vue.js project using vue init webpack project_name,after this step I ran npm install. and npm threw out errors below:
npm ERR! path /Users/duodian/Desktop/crop-demo/node_modules/js-
beautify/js/bin/css-beautify.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod
'/Users/duodian/Desktop/crop-demo/node_modules/js-beautify/js/bin/css-beautify.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/duodian/.npm/_logs/2017-09-18T09_55_20_047Z-debug.log
node version 8.5.0
npm version 5.3.0
Note: I just updated my macOS HighSierra to 10.13 Beta, does this affect?
had any friends have this problem?
Running
npm install js-beautify#1.6.14
and then
npm install (assuming that you are installing deps in package.json)
worked for me. Got it from here.
https://github.com/beautify-web/js-beautify/issues/1247
It's bacause of js-beautify#1.7 i broken. So, try to downgrade vue-cli to 2.7.0 is a temporary workaround to solving this problem
npm install -g vue-cli#2.7.0

`no such file or directory` While installing js beautify in npm

I get this error when i use npm -g install js-beautify
npm ERR! path /home/developer/software/nodejs/lib/node_modules/js-
beautify/js/bin/css-beautify.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod
'/home/developer/software/nodejs/lib/node_modules/js-
beautify/js/bin/css-beautify.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/developer/.npm/_logs/2017-09-18T07_52_38_910Z-
debug.log
What can be done to solve this?
I am using node 8.5.0 an npm 5.3.0
JS-Beautify 1.7.0 is broken.
Explicitly install the last good version:
npm -g install js-beautify#1.6.14
… or wait for a fixed version to be released.
The fix for me was to add to package.json:
"devDependencies": {
"js-beautify": "1.6.14",
and
"resolutions": {
"js-beautify": "1.6.14"
}
then delete the node_modules/ directory
and finaly reinstall all of the dependencies using npm install (for some reason yarn would fail - even after deleting yarn.lock)