How do I uninstall "nodebrew"? - node.js

Hi I'd like to uninstall nodebrew from my mac local computer.
https://github.com/hokaccha/nodebrew
I took a look at the page above but couldn't find how to unstall it.

There doesn't seem to be any command for uninstalling (as opposed to setup for installation). What I did was:
uninstall all node versions that were installed with nodebrew:
nodebrew ls (to list all installed node versions)
nodebrew uninstall <node_version> (run this per each version of node listed with the previous command)
remove NODEBREW_ROOT environment variable set in .bashrc/.zshrc
remove ~/.nodebrew if exists: rm -rf ~/.nodebrew
remove nodebrew itself (mine was installed in /usr/local/var/nodebrew/, so I did rm -rf /usr/local/var/nodebrew).
Above steps should do, but please let me know if I missed anything.

Usually you uninstall with npm command. Open a command line go to the folder of the project and type:
npm uninstall nodebrew

Related

MacOS, where to remove a reference to old Node.js

I used to have Node.js 8.x.x installed on my Mac. Then I tried to upgrade it using Homebrew. For some strange reason, Node 8 was not removed.
Then I did brew remove node and sudo rm -rf /usr/local/Cellar/node#8/
and then brew install node again.
Now, when I run node -v I get this:
-bash: /usr/local/opt/node#8/bin/node: No such file or directory
Does anyone know what place should I clean to remove a reference to this path?

Error: Cannot find module '../lib/utils/unsupported.js' while using Ionic

I always get this error message when I run "Ionic start project name":
Error message
Running command - failed![ERROR] An error occurred while running npm install (exit code 1):
module.js:471
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:79:3)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
Try to remove /usr/local/lib/node_modules/npm and reinstall node again. This should work.
On MacOS with Homebrew:
sudo rm -rf /usr/local/lib/node_modules/npm
brew reinstall node
I followed the previous answers and reinstalled node. But I got this error.
Warning: The post-install step did not complete successfully You can
try again using brew postinstall node
So I ran this command
sudo chown -R $(whoami):admin /usr/local/lib/node_modules/
Then ran
brew postinstall node
I received a similar error and now have it working.
First make sure you have the latest version
brew update
Remove your previous instance of node:
brew uninstall node
Then reinstall the latest version:
brew install node
And then make sure it is symlinked into /usr/local if it isn't already. You would get an error to let you know to complete this step.
brew link --overwrite node
More details on how to install/upgrade node are also available.
On Mac OS X (10.12.6), I resolved this issue by doing the following:
brew uninstall --force node
brew install node
I then got an error complaining that node postinstall failed, and to rerun brew postinstall node
I then got an error:
permission denied # rb_sysopen /usr/local/lib/node_modules/npm/bin/npx
I resolved that error by:
sudo chown -R $(whoami):admin /usr/local/lib/node_modules
And now I don't get this error any more.
If you are using "n" library # https://github.com/tj/n . Do the following
echo $NODE_PATH
If node path is empty, then
sudo n latest - sudo is optional depending on your system
After switching Node.js versions using n, npm may not work properly.
curl -0 -L https://npmjs.com/install.sh | sudo sh
echo NODE_PATH
You should see your Node Path now. Else, it might be something else
The error Cannot find module '../lib/utils/unsupported.js' is caused by require('../lib/utils/unsupported.js') in ./lib/node_modules/npm/bin/npm-cli.js.
According to the nodejs require docs, the required module is searched relative to the file, as it starts with ../.
Thus, if we take the relative path ../lib/utils/unsupported.js starting from ./lib/node_modules/npm/bin/npm-cli.js, the required module must reside in ./lib/node_modules/npm/lib/utils/unsupported.js. If it is not there, I see two options:
the installation is corrupt, in which case Vincent Ducastel's answer to reinstall node might work
npm is no symlink to ./lib/node_modules/npm/bin/npm-cli.js. This is what caused the error in my setup. If you call npm, it will typically find it be searching it in the directories listed in the PATH env var. It might for example be located in ./bin. However, npm in a ./bin directory should only be a symlink to the aforementioned ./lib/node_modules/npm/bin/npm-cli.js. If it is not a symlink but directly contains the code, somewhere in the installation process the symlink got replaced by the file it links to. In this case, it should be sufficient to recreate the symlink: cd ./bin; rm npm; ln -s ../lib/node_modules/npm/bin/npm-cli.js npm (update: command fixed, thx #massimo)
All answers that suggest to check the NODE_PATH or the npmrc config should be ignored, as these are not considered when searching modules relatively.
As mentioned earlier.
sudo rm -rf /usr/local/lib/node_modules/npm
brew uninstall --force node
brew install node
Tried all above/older brew installation answers, none is working for my laptop.
Only below method could fix my issue.
1) Run following commands:
sudo rm -rf /usr/local/lib/node_modules/npm
brew uninstall --force node
2) Then, proceed to Node.js Official Website https://nodejs.org/en/download/current/ to download latest package for new installation.
3) Run your npm command again, which should longer have any errors.
This method is working on macOS Mojave Version 10.14.4.
https://nodejs.org/en/
Simply download node from the official website, this worked for me! :)
On Windows:
Remove the npm folder in ~/AppData/Roaming
Yes you should re-install node:
sudo rm -rf /usr/local/lib/node_modules/npm
brew uninstall --force node
brew install node
Simply follow three steps;
Clear npm cache forcefully:
npm cache clean -f
Install n package globally using npm:
npm install -g n
Install from any of three options:
a. sudo n stable (get the stable version)
b. sudo n latest (get the latest version of node)
c. sudo n x.x.x (get the specific version of node)
I got this error by mixing install/update methods: installed node via downloading package from website and later I used brew to update.
I fixed by uninstalling the brew version :
brew uninstall --ignore-dependencies node
Then I went back to node website and downloaded and installed via the package manager: https://nodejs.org/en/download/
For some reason, no amount of trying to reinstall via brew worked.
I was running into a similar issue where the whole ../lib/utils directory couldn't be found when I tried executing Mocha via npm test. I tried the mentioned solutions here with no luck. Ultimately I ended up uninstalling and reinstalling the Mocha package that was a dependency in the npm project I was working in and it worked after that. So if anyone's having this issue with an npm package installed as a dependency, try uninstalling and reinstalling the package if you haven't already!
I solved this issue by running below command
nvm install node --reinstall-packages-from=node
In my case it was $NODE_PATH missing:
NODE="/home/ubuntu/local/node" #here your user account after home
NODE_PATH="/usr/local/lib/node_modules"
PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$NODE/bin:$NODE/lib/node_modules"
To check just echo $NODE_PATH empty means it is not set. Add them to .bashrc is recommended.
On fedora 27 I solved the problem by doing this:
sudo rm -f /usr/local/lib/node_modules/npm
sudo dnf reinstall nodejs
This is a helpful video and blog post about removing node from your computer OS. It is a different method of removal based on how you installed node in the first place (brew vs. binary file downloaded from https://nodejs.org/en/
if you installed node with Homebrew then brew uninstall node will work. Verify that with running a node -v command in your terminal.
Otherwise and if you have installed the binary file from nodeJS's websitethen you have to run this command in your terminal: sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}. Again, verify that with running a node -v command.
In both cases, successful removal of node should result in bash not recognizing what node is if it is completely removed
In my macOS (10.13.3), I got it solved after reinstalling Node version manager.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
source ~/.bashrc
This may happen when the npm/lib folder got emptied for some reason (could also happen due to permission issues in the last usage).
A reinstallation of the node could solve the issue (as stated on other answers here), but I would suggest using a wonderful tool called nvm (Node Version Manager), which is able to manage multiple version of node and npm - this is mostly useful on dev machines with more than one projects require different versions of node.
When you install nvm, this message will go away and you will have the latest version of node and npm to use.
In order to see the list of currently installed node versions in your nvm, just run:
nvm list
In order to install and use a new node version, run:
nvm install <node_version>
For example to install latest version of node 10.x, run:
nvm install 10
In order to switch to currently installed version, run:
nvm use <node_version>
In order to switch to system's original node version, just run:
nvm use system
Hope this helps.
Good luck!
I solve this issue by removing node_modules and then reinstall node stable version.
You can run this command it will automatically remove the previous version of npm and install new version for details https://github.com/npm/cli
curl -qL https://www.npmjs.com/install.sh | sh

Global Node Packages Installed to Wrong Directory

I'm trying to install Hexo globally using npm. When I run
npm install -g hexo-cli
I'm informed that it was installed to /Users/myusername/.node/bin/hexo -> /Users/myusername/.node/lib/node_modules/hexo-cli/bin/hexo
The problem comes in when I run hexo init blog and the hexo command is not found.
I installed Node and npm with Homebrew, so when I run which node and which npm, the results are /usr/local/bin/node and /usr/local/bin/npm respectively.
I'm thinking that I still have leftover files and directories from when I installed Node without homebrew, but I don't want to start deleting things without fully knowing the repercussions. Would I be safe to delete all files located in the /Users/myusername/.node/ directory? I can't figure out why npm is not installing to the proper directory.
After a little digging, I found that my npm prefix variable was pointing do the wrong directory, left behind by the old Node installation. I ran npm config get prefix to see where it was pointing.
I set the new prefix value using npm config set prefix /usr/local. Homebrew is symlinked with this directory via /usr/local/bin. I uninstalled hexo-cli and reinstalled through npm, and now it works perfectly.
For NVM users
Run nvm use --delete-prefix v10.13.0 --silent replacing v10.13.0 with whatever version of node you're using.
A simple way to cope with environment variables/path problems on Windows:
Run command:
npm install -g hexo
Using node.js command prompt rather than cmd windows provided by Windows itself.

Why is node-gyp rebuild failing on Mac OSX El Capitan

I recently bought a mac, which uses Mac OSX El Capitan v10.11.4. Installed node with homebrew, and am using node v6.2.2 and npm v3.9.5. I'm getting an error with bcrypt during npm install, which I believe derives from a node-gyp rebuild error. I also recently downloaded xcode-select(version 2343) and xcode(7.3.1) (in that order).
Here is the full error output after i run npm install:
https://gist.github.com/varunjayaraman/5734af617d616437cd5b3456b20bc503
Not sure what's going wrong. I come from linux land and do tend to be wary of not installing from source myself, so maybe that is the cause of these issues? Anyway, any advice would be super appreciated. I also saw this error springing up for others, but none of their solutions seemed to work (when i type xcode-select --print-path, I get /Applications/Xcode.app/Contents/Developer)
Anytime i upgrade OSX to newer version, I get the same issue.
Here is how i solve it every time:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
That's it. Now next time you do npm install or yarn it'll work.
PS: Sometimes you won't be able to install the command line tool through Xcode-select, for example if you are on beta.
In that case, you should be able to install it manually from here: https://developer.apple.com/download/more/
This one just bit me, too. There were a couple of different solutions, only one of which worked for me.
First, make sure you have the XCode command line tools installed, as they say on their npm page.
1) The simplest solution, which of course didn't work (though it looks like it did for some people), is to just delete the ~/.node-gyp directory. So might as well give that a shot, as well as deleting your node_modules dir and doing another npm install.
2) Try uninstalling node-gyp and re-installing:
sudo npm uninstall node-gyp -g
npm uninstall node-gyp
npm install
3) But what did the trick was a solution given in a node-gyp issue on github, where you have to install another version of node and do your npm install that way. It's easier than it sounds, but it's pretty gross:
sudo npm cache clean -f
sudo npm install -g n
sudo n 4.4.5
sudo npm install npm -g
sudo npm uninstall node-gyp -g
Then try running npm install.
Hope that helps!
If the node_modules cache was built with a recent version of Node, you may need to remove the cache, revert back and then reinstall the packages:
rm -rf node_modules
nvm use 6
npm install
I have a simple solution. If the xcode-sellect is installed try running
sudo xcode-select --reset
Same issue I had after upgrading macOS
Update brew
brew update
Update X-Code
xcode-select --install
If needed, you may have to reset the path to X-Code
xcode-select --switch /Applications/Xcode.app
xcode-select --switch /Library/Developer/CommandLineTools
For anyone who tried reinstalling Xcode tools yet the same issue persists.
You will have to go following file:
~/.node-gyp/<your_node_version_here>/include/node/common.gypi
Note: Make sure to change <you_node_version_here> to your node version like:
~/.node-gyp/16.13.1/include/node/common.gypi
You can find node version using
node -v
Inside search for key MACOSX_DEPLOYMENT_TARGET and change it's value to your current os version like mine is 11.3.1 and you will be good to go.
You can find version in
about this mac
option in drop down of mac logo
If you are using virtualenv for your python, you need to deactivate it or point npm to use the OS's own python 2 installation for node-gyp to work.
EDIT:
Had another encounter with the same bug a few days ago. This time around node-gyp was not at fault. Apparently the module I was installing has a dependency on a very old version of node-gyp (v1), independent of the system's version (v3.8), which my version of node (v10) no longer supports. Since I did not need that module anymore, I removed it. Alternatively, you may wish to upgrade/downgrade/replace the offending module, or upgrade/downgrade your node. For the OP's case, the offending module was bcrypt#0.8.5.
if you want to upgrade Node to 10 or above, you have to find dependencies out of date with Node 10 in package.json and upgrade these packages to newer stable version, then build (npm/yarn install).
Try looking at your python install.
I found a hint at the discussion here https://github.com/nodejs/node-gyp/issues/489#issuecomment-431447692.
My python on my MacBook Pro is managed by Homebrew which installs binaries to
/usr/local/bin
So I did the following in terminal:
>$: npm config set python /usr/local/bin/python
>$: rm -rf node_modules
>$: npm i
I had a similar issue.
A lot of folks have recommended that you install Xcode, and point xcode-select to the /Applications/Xcode.app/Contents/Developer. However, there is one more step.
That is to confirm that the /Applications/Xcode.app/Contents/Developer folder has SDK version corresponding to the MacOS version your actual computer is running on.
If it does not, go into /Library/Developer/CommandLineTools and copy that over.
I had a similar issue and running the commands below fixed it for me
Install xcode
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
You need to re-install XCode Tool in order to compile your codes in your machine:
* xcode-select -print-path
* sudo xcode-select --reset
* xcode-select -print-path
Here's the main link you can install it on MacOS:
https://github.com/nodejs/node-gyp/blob/main/macOS_Catalina.md

NPM Command Not Found After Installing Node

I am having a very hard time getting the npm command to work, and unfortunately my knowledge of unix isn't good enough to solve this on my own. All I've done is brew install node, and I get the following errors:
When I type npm I get zsh: command not found: npm
Looking into this issue more I found this stack overflow answer:
Command not found after npm install in zsh
Following its advice I tried adding export PATH=/usr/local/share/npm/bin:$PATH to my .zshrc file. Still get the same error when typing npm
I can confirm it is in the path echo $PATH yields /Users/nicholashaley/.rbenv/shims:/Users/nicholashaley/.rbenv/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/usr/local/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/Users/nicholashaley/.rbenv/shims:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
I can also confirm that node has been installed node -v yields v0.12.2
Any ideas? I'm stumped
Not an answer, but maybe a solution...
Uninstall Node via brew: brew uninstall node
Then download Node from https://nodejs.org/en/download/ and install.
npm should then "just work".
I came across to this thread with the same problem but finally below is what worked for me which is without sudo
$ brew update
$ brew uninstall node
$ brew install node
$ chown -R YourUserName /usr/local/lib/node_modules/
$ brew postinstall node #This what the important step
Ok this is what worked for me:
$ brew update
$ brew uninstall node
$ brew install node
$ sudo brew postinstall node #This what the important step
In case this never got solved, this is what worked for me:
brew uninstall node
brew install node
brew doctor and see what needs to be pruned. My problem was there was a non-brew place where I had changed my install location for npm packages because I was trying to get an npm package to install for me. That was a mistake (having forgotten I initially installed node and npm through brew but now brew could no longer reach the npm install directory nor could it change or delete it). So brew prune didn't work even though the symlinks were supposedly deleted but it reminded me that I had changed the npm install location. And that brings us to:
Delete those directories
brew postinstall node
Hope it helps.
I found this article helpful with step-by-step details:
https://www.dyclassroom.com/howto-mac/how-to-install-nodejs-and-npm-on-mac-using-homebrew
Additionally, after all the steps in above article, node was working but my machine was still giving "command not found: npm". I then ran the following two commands and npm was working.
sudo chown -R myusername:myusergroup /usr/local/lib/node_modules
brew postinstall node
Anyone on the LTS release use the following command instead:
brew postinstall node#6
Issue Details in Gist and how I fixed it
1. Installed nodeJs via nvm using Git Bash
2. Installed hyper terminal & WSL
3. Installed Ubuntu (windows Store) & configured zsh shell.
4. Faced the command not found all over in the zsh shell
5. The same commands are working nicely in the bash shell
Tried sourcing the (node, nvm, npm ) paths in the .zshrc and .profile file &
modified the System & Environment Variables in Windows. None of these steps helped me to resolve the issue.
I think the issue is zsh and bash terminals treat things differently. When Installed in bash terminal the default location for the nodeJs in windows will be set to
C:\Users\Program Files\nodejs
The above one is symlinked to C:\Users\<username>\AppData\Roaming\nvm
No matter how much I tried to alias these things in zsh, only node and nvm are working with aliases. npm is failing to locate the necessary lib files.
The only solution that worked for me is Re-installing node in zsh terminal
Removed the node versions installed via nvm in Bash terminal.
Removed the nvm in windows via control Panel
Installed the nvm in the zsh shell
Installed the node latest LTS version from which npm is also installed.
Post Installing the node via nvm in Zsh I observed the following things.
Paths for the node, nvm, npm & npx have been automatically added to the $PATH variable
Node directory is not available neither in C:\Users\Program Files\nodejs
nor the C:\Users\{username}\AppData\Roaming\nvm
Instead it is configured differently at /home/<username>/.nvm/versions/node/v14.15.1/bin/node
This video really helped me in re-installing the node in ZSH: https://www.youtube.com/watch?v=kL8iGErULiw
Usually npm should be found in the same directory as that of the node executable, which can be determined by which node. Check if this directory is part of your PATH. If node was installed through a node version managers such as nodenv and nvm, check the documentation for how to add these executables to the path.
With nodenv, this can be done with:
eval "$(nodenv init -)"

Resources