Node and npm installation using brew - node.js

I am doing some setup whcih required me to uninstall earlier node and npm setup, and install again using brew. But when i uninstalled it, and then installed it using brew install node, it gives me an error "bash: /usr/bin/npm: No such file or directory"
I uninstalled them once again, and when I type node (to see which path it is called in) I get, "bash: /home/username/.linuxbrew/bin/node: No such file or directory"
Whereas if I type npm I get, "bash: /usr/bin/npm: No such file or directory"
I think maybe the reason of error is this discrepancy in both the paths. Any suggestions on how to install it correctly using brew?

You made the same mistake I did. There are bad instructions on the internet for how to install node which come up on top on Google. They say install npm separately. Wrong. npm is included with nodejs (It's not called "node" either. Nodejs will tell you that the name "node" is a different program by a different author.)
Follow these instructions:
https://nodejs.org/en/download/package-manager/

Related

Why is it that npm install doesn't work on my device and I am unable to view the version details even though I've reinstalled?

I'm completely new to using Node and am honestly very confused about how this all works. I have installed node and NPM but every time I try to check the version to see if it's installed, it tells me "command not found". I've been at this for almost 2 hours just deleting all the npm/node files and reinstalling but nothing seems to give. Can someone please explain if there is anything I can do to fix this issue?
-bash: npm: command not found
If I go inside the NPM file through the terminal, it shows me this when I try to run npm install or npm start.
> npm start
npm should be run outside of the Node.js REPL, in your normal shell.
(Press Ctrl+D to exit.)
Add npm to your path (environment variable on windows not sur on linux) if you are using a portable version, if you are using an installed version of node, it should add npm to your path automatically on windows, not sure on linux, npm start will run the start script from your project package.json file. try going into your npm executable folder (generally in node installation folder), n do a ./npm i -g npm

-bash: npm: command not found after using Node LTS installation package

I have tried installing Node (and therefore also npm) using the current LTS installer package from their website, which all seemed to go ok. However, when I try using the npm command I get -bash: npm: command not found
As per answers elsewhere on this site I tried the installer again but fared no better. /usr/local/bin is in my $PATH and there is an npm listed in that directory which links to a file called npm-cli.js elsewhere, but when I which npm nothing comes up.
Do I have to add something else to my $PATH?

Cant start Node-red

I've tried to install Node-red on Sierra. Used brew to install node and Npm. Then I just followed the instructions on Node-red, but for some reason I can't run Node-red to start it up. I get error message "command not found" ... I've googled like a maniac, without results.
What can I do?
Info:
Osx Sierra 10.13.xx
Node Version 9.11.1
Npm Version 5.6.0
Brew doctor comes out clean.
Brew is updated.
It sounds like the directory that npm links the executables provided by node modules is not on your path.
Try running $(npm get prefix)/bin/node-red in a terminal. If that works, you should add the directory returned by echo $(npm get prefix)/bin/ to your path.
See also: https://superuser.com/questions/1081769/after-npm-install-g-command-still-not-found

I can't install npm not matter what I do

So I'm trying to get myself a good Discord Selfbot and one of them requires nodejs, then it said to do npm install. But it gave me an error. I tried again again again and again but nothing worked. The latest thing I did was installing nodejs via scoop but I get this error trying to install npm. Is there a way to do this manually or something? I've tried installing different versions but nothing. I believe scoop installed the latest version.
Here's the image. (the red squares cover up just names)
You have npm already installed, seems that the problem is you don't have a package.json in that location. It says ENOENT: No such file or directory
You already have npm installed! npm is a package manager for installing nodejs packages. Try running some nonsense command (like "lkajshdflhsf") and you'll see what it looks like if you actually didn't have npm installed. What npm install does is install some package. So, for example, if you want to install a node package called Blah, you would run npm intall blah.

npm comes with node now. What does this mean?

Node noob here.
I had previously installed both npm and node separately.
Apparently, npm comes with node now. (link)
To my newbie mind, this means my previous dual installation is old and ugly. 1 binary > 2 binaries. So i uninstalled both.
Then I installed the latest node following the procedure. (i am running eOS)
Terminal
user#box:-$ which node
/usr/bin/node
user#box:-$ node -v
v0.10.22
user#box:-$ which npm
user#box:-$ npm -v
bash: /usr/bin/npm: No such file or directory
I can always run:
curl https://npmjs.org/install.sh | sh
but that seems to indicate that npm is actually NOT included in node.
When they say they are included do they just mean the code is in the same repo, but the binaries are still different?
Final question I have /usr/bin/node as well as /usr/bin/nodejs
can i delete one of these? im not sure when/where i picked up a second copy.
Yes, the nodejs package includes both node and npm executables. The code for each has its own repo, but when packaged both are included.
npm source: https://github.com/isaacs/npm
node source: https://github.com/joyent/node
When you install that .deb file from the PPA, you should get both /usr/bin/nodejs and /usr/bin/npm and 2 symlinks at /usr/bin/node (which points to) /etc/alternatives/node (which points to /usr/bin/nodejs).
If any of this isn't true, your install didn't fully succeed, most likely due to conflicting files you left around from your manual install. I would suggest uninstalling the .deb then making sure there are no stale files left from your manual install and then installing again.
Only node.js packages comes with npm. so if you are installing using an .msi, .exe, .dmg .pkg, .deb or using a package installer like apt-get, yum or brew, then you'll have both node and npm.
However,npm is not part of the node core. if you are installing node and using a method where you are using ./configure or make install || make link, then npm will not be installed, and will need to be compiled using the same type of installation, and node will have to be placed on your path.
If you used git, or unzipped node and you can see a configure script, then you will also need to acquire npm.
I've had issues (mostly on Mac) with npm ending up in directories that aren't in the terminal PATH. If you can figure out where npm is located, you can just add it to your path with something like:
export PATH=$PATH:/path/to/npm
I think (I'm not on a mac so I can't check at the moment) that it sometimes gets put in /usr/local/share/. But at any rate, the problem is likely NOT that npm isn't installed, but that it's installed somewhere you're not expecting.
Few months ago i had started learning the react so all this stuff i needed to install my laptop that had the ubuntu operating system.
What i did -- First i installed the node and without knowing that it came up with the npm package. I installed the npm package again.. but there was no conflict at all.
But after exploring all these things that nodejs have npm package. So i uninstalled the npm package due to concern about memory usage..
And Now everything is working fine....

Resources