npm broken after installing via brew - node.js

So i'm installing node, npm and cordova+ionic on my mac (High Sierra) and it's giving me this issue:
Julime-Air:~ julime$ brew install node
==> Downloading https://homebrew.bintray.com/bottles/node-9.3.0_1.high_sierra.bottle.tar.gz
Already downloaded: /Users/julime/Library/Caches/Homebrew/node-9.3.0_1.high_sierra.bottle.tar.gz
==> Pouring node-9.3.0_1.high_sierra.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/node/9.3.0_1: 5,125 files, 49.6MB
Julime-Air:~ julime$ npm install npm#latest -g
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
+ npm#5.6.0
updated 1 package in 16.966s
Julime-Air:~ julime$ npm -v
5.6.0
Julime-Air:~ julime$ npm install -g cordova ionic
npm WARN deprecated node-uuid#1.4.8: Use uuid module instead
npm ERR! path /usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/ansistyles
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/ansistyles' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/.ansistyles.DELETE'
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/julime/.npm/_logs/2017-12-15T22_50_54_958Z-debug.log
tried reinstalling but no luck
Edit:
Running as sudo does not help.
Edit2:
Installing Node via mac installer does also not help.

After having some trouble removing that mac-installer-node, i think this fixed my problem:
sudo chown -R $USER /usr/local
brew doctor
brew link --overwrite node
If you had the same issue, please comment if this helped.

Related

uninstalling broken node packages for react native

I am working on a react native app and I had to install node and expo-cli to start the app but recently I have been having issues with running the app. When I run npm start, I get the error expo: command not found so I install the expo-cli using npm install --global expo-cli I get this error:
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /Users/{usr}/.npm-global/lib/node_modules/expo-cli
npm ERR! dest /Users/{usr}/.npm-global/lib/node_modules/.expo-cli-F3yBqKce
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 501:20 "/Users/{usr}/.npm"
I ran the sudo chown -R 501:20 "/Users/{usr}/.npm command but it still does not work.
So I tried to uninstall node and start all over but the issue still persists. Does anyone know a way to fix these issues? Like is there a way I can reset my packages or something like that?
Thanks in advance!

How to update npm in WSL 2 Ubuntu

I'm trying to update my ancient npm 3.5.2 that is running in the Windows Subsystem for Linux on my Windows 10 to the latest version.
The command I'm running is as follows:
sudo npm install -g npm#latest
However, it fails and all I'm getting is the following output:
WARN engine npm#7.20.5: wanted: {"node":">=10"} (current: {"node":"8.10.0","npm":"3.5.2"})
/usr/local/lib
└── (empty)
sudo apt install wsl
npm ERR! Linux 5.10.16.3-microsoft-standard-WSL2
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "npm#latest"atest
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! path /usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552' -> '/usr/local/lib/node_modules/npm/node_modules/#npmcli/ci-detect'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552' -> '/usr/local/lib/node_modules/npm/node_modules/#npmcli/ci-detect'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /mnt/d/Summbit/Humanatomy.Web/npm-debug.log
npm ERR! code 1
I'm clueless what npm is trying to tell me. Does anyone know what is going on here?
I found this article that detailed the steps that eventually enabled me to update npm. These are the steps that I followed:
Step:
sudo npm cache clean -f
output:
npm WARN using --force I sure hope you know what you are doing.
Step:
sudo npm install -g n
output:
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
/usr/local/lib
└── n#7.3.1
Step:
sudo n stable
output:
installing : node-v14.17.4
mkdir : /usr/local/n/versions/node/14.17.4
fetch : https://nodejs.org/dist/v14.17.4/node-v14.17.4-linux-x64.tar.xz
installed : v14.17.4 (with npm 6.14.14)
Note: the node command changed location and the old location may be remembered in your current shell.
old : /usr/bin/node
new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"
Step:
sudo n latest
output:
installing : node-v16.6.1
mkdir : /usr/local/n/versions/node/16.6.1
fetch : https://nodejs.org/dist/v16.6.1/node-v16.6.1-linux-x64.tar.xz
installed : v16.6.1 (with npm 7.20.3)
Step:
Close the shell and open a new one
Step:
npm --version
output:
7.20.3
There's a workaround:
npm install -g yarn
yarn global add npm
~/.yarn/bin/npm install -g npm
Some thing to note:
my nodejs was installed using nvm under ~/.nvm
you need to close vscode if you have it running in wsl mode, and restart bash. some file might be hold by vscode-server process.

ERRORS: Trying to install truffle to terminal

I'm completely new at this and keep getting an error message trying to install truffle. If I need to delete or add anything please explain in detail how to do so.
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/paulbrady/.npm-global/lib/node_modules/truffle
npm ERR! dest /Users/paulbrady/.npm-global/lib/node_modules/.truffle-f258BAu1
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/paulbrady/.npm-global/lib/node_modules/truffle' -> '/Users/paulbrady/.npm-global/lib/node_modules/.truffle-f258BAu1'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/paulbrady/.npm/_logs/2021-05-19T09_32_00_700Z-debug.log
paulbrady#Pauls-MacBook-Air ~ %
I had similar issue and this is how I solved it
Remove the already installed truffle
sudo -i
cd /usr/local/lib/node_modules/
rm -r truffle .truffle_
Make sure Ganache is running first before reinstalling truffle again
Install Truffle: npm install -g truffle

npm ERR while installing ionic

I am on Windows 10 trying to install Ionic. I ran the following code in the terminal:
npm install -g #ionic/CLI
And I get this error:
npm ERR! code EEXIST
npm ERR! path C:\Users\Lari\AppData\Roaming\npm\ionic.ps1
npm ERR! Refusing to delete C:\Users\Lari\AppData\Roaming\npm\ionic.ps1: is outside C:\Users\Lari\AppData\Roaming\npm\node_modules\#ionic\cli and not a link
npm ERR! File exists: C:\Users\Lari\AppData\Roaming\npm\ionic.ps1
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 can be found in:
npm ERR! C:\Users\Lari\AppData\Roaming\npm-cache\_logs\2020-08-12T22_24_22_577Z-debug.log
I have ran the following commands to debug:
npm uninstall -g ionic
npm install -g #ionic/cli
npm install -g cordova #ionic/cli
and much more for over a week now.
I copied and paste this path in windows
C:\Users\Lari\AppData\Roaming\npm\ionic
Deleted all ionic folders, and then this path
C:\Users\Lari\AppData\Roaming\npm
Deleted some ionic files present as well.
Ran npm I -g #ionic/cli and it did install version 6.11.0.
Thanks everyone, hope it helps someone

Angular 2/4 npm install issue

When i try to to install angular via npm i get this error message:
npm install -g #angular/cli
npm ERR! path C:\Users\myname\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\acorn
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\myname\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\acorn' -> 'C:\Users\myname\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\.acorn.DELETE'
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! C:\Users\myname\AppData\Roaming\npm-cache\_logs\2017-07-26T15_20_28_022Z-debug.log
current setup:
node -v
v6.11.1
npm -v
5.3.0
VOILA!! I found the answer. Actually i can't claim that is a real answer to the problem but it worked damn well. So what i did is, i ran bash as administrator (i did this many times before but didn't worked), and i did next:
$npm cache verify (to see what will happen after i deleted some stuff, uncompleted angular package in node_modules directory for example)
$npm update ( update all outdated local packages )
$npm update -g ( update global packages )
$npm install -g #angular/cli
Maybe running bush as administrator wasn't necessary, maybe just npm update was enough. Anyway, i hope this solution will be helpful to someone.

Resources