Changing PATH for npm node_modules - npm

I've been troubleshooting problems with using npm packages for about 2 weeks now. Any node modules (I've tried gulp, gulp-cli, mocha, react, babel, and others) return a "command not found" error in Git Bash.
I have Windows 7 Professional, Node 8.11.1 (64-bit), npm 5.6.0.
What I have tried already is:
In the case of gulp-cli for Lecture 11 of this course
-- Uninstalling the package globally and reinstalling globally
-- Uninstalling and re-installing Node and npm completely
-- Changing the PATH and NODE_PATH of the Environment Variables
User variables
PATH:C:\Program Files\Git\usr\local\node_modules\;C:\Users\Millionaire\AppData\Roaming\npm;
System variables
PATH: C:\Program Files\Git\usr\local\node_modules\;%USERPROFILE%\AppData\Roaming\npm;
$ which node
/c/Program Files/nodejs/node
$which npm
/c/Program Files/nodejs/npm
$ npm list -g
C:\Program Files\Git\usr\local
Any help you can offer is very much appreciated!

I tried a few times to do
$npm list-g {package name}
for gulp and http-server and others and it kept giving me
C:\Program Files\Git\usr\local
So I added that to the system PATH environment variable. Exited and restarted Git Bash and it finally worked for me. Hallelujah.

Related

npm doesn't uninstall packages

I've been trying to remove some packages that I installed with npm but it doesn't remove them. After running npm uninstall -g package the package is still executable in my terminal and it is still in the path where npm binaries are being installed.
Also, why is npm installing packages in ~/.local/share/npm/bin/ ? It's the first time that I've seem npm installing packages there. I had a problem a few weeks ago when installing some language servers but they weren't executable, turns out I had to add ~/.local/share/npm/bin to my $PATH because that's where npm was installing everything. And now npm doesn't remove any package installed there. I've already look into the npm config (npmrc) but I don't see any option changing the install path. The only environment variable related to npm that I have is to set the user config in ~/.config/npm instead of ~/.npmrc.
I have others machines with the exact same settings and npm it's not installing packages in ~/.local/share/npm/bin/ and I'm able to uninstall packages normally.
Does anyone knows whats wrong with npm ?
npm --version 7.8.0
my config:
cache=/home/user/.cache/npm
init-module=/home/user/.config/npm/config/npm-init.js
package-lock=false
tmp=/run/user/1000/npm
Okay I noticed that if I reinstalled the packages that I couldn't remove they went into a different folder /user/bin/ with the node_modules being in /user/lib/node_modules. Before it was in ~/.local/share/npm/lib. Now with the packages were they belong I can't remove them without issues. No idea why those packages were originally installed in a different path.

NPM global package install not working properly

Tearing my hair out over this.
I used to have a npm package called 'eleventy' installed globaly and working on my laptop. Today I find this: fish: Unknown command 'eleventy'
Tried this npm install -g eleventy and got this
+ eleventy#0.2.0
updated 1 package in 0.289s
Things tried from other posted questions:
npm get prefix outputs /usr/local
ls /usr/local/lib/node_modules/ outputs eleventy npm
but not eleventy found in /usr/local/bin
echo $PATH = /usr/local/php5/bin/ /usr/local/bin /usr/local/lib /usr/bin /bin /usr/sbin /sbin
Tried reinstalling npm and nodejs as well but no luck so far. Any help appreciated.
Okay, looks like I'm an idiot. I was installing the wrong package with a similar name.
I needed to use
npm install -g #11ty/eleventy

VS Code terminal fails to use npm version from nvm

I'm using nvm on my Terminal and successfully installed node 10.2.1, which also installed npm 6.1.0. However, when I go to my VS Code editor, it gives me warnings in the integrated terminal for:
npm WARN npm npm does not support Node.js v10.2.1
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4,6, 7, 8, 9.
Turns out, it is actually using npm 5.5.1 (npm -v).
I check to see what's up with that and tried to dig further and eventually used: which npm on both integrated terminal and Mac's CLI.
Mac's Terminal shows:
/Users/Aiz/.nvm/versions/node/v10.2.1/bin/npm
VS Code's Terminal shows:
/usr/local/bin/npm. Which is interesting, because if you do which node in this terminal, it results in the appropriate /Users/Aiz/.nvm/versions/node/v10.2.1/bin/node.
I'm not sure how to get my VS Code terminal to point to the appropriate npm install through nvm. Not sure if it helps, but I checked npm get prefix and npm -g bin to find /Users/Aiz/.nvm/versions/node/v10.2.1. The only difference I'm finding is where each terminal is using npm from.
I ended up looking through VS Code issues on GitHub and came across something relevant to NVM and node issues. It fixed my issue since the underlying cause was the same.
Essentially what happened is that I had a global install of node before that I removed prior to using NVM but hadn't removed my global install of npm. This was causing conflicts in VS Code's terminal (not Mac's terminal). In order to fix this, you essentially have to find the symlink for which npm and remove the node_modules and npm associated recursively.
Here's the link you'll need: https://github.com/Microsoft/vscode-docs/blob/master/docs/editor/integrated-terminal.md#why-is-nvm-complaining-about-a-prefix-option-when-the-integrated-terminal-is-launched.
Don't forget to restart your editor after.
Another solution is to implement this. https://medium.com/#kinduff/automatic-version-switch-for-nvm-ff9e00ae67f3
Basically, nvm will check for a .nvmrc and switch or default each time you go to a new directory in shell.
It does have a dependency on zsh.
The fix for me on Ubuntu:
A.) sudo apt-get remove nodejs npm
B.) Removed lines in my .bashrc that added the npm package directory to the path.
C.) Restart VS Code.
I doubt step A is necessary. But B and C certainly are.

Issue installing bower on windows

I'm using Windows 7 64bit and I install Bower with
npm install -g bower
It seems to install correctly.
npm http GET https://registry.npmjs.org/amdefine
npm http 304 https://registry.npmjs.org/amdefine
C:\Program Files (x86)\Git\local\bower -> C:\Program Files (x86)\Git\local\node_
modules\bower\bin\bower
bower#1.3.3 C:\Program Files (x86)\Git\local\node_modules\bower
...
But bower is not working:
$bower
sh.exe": bower: command not found
$bower -v
sh.exe": bower: command not found
What could be wrong?
Same problem but for me I had to add the Path Environment Variable that pointed to the AppData/Roming/ folder. I have no idea why node.js would install npm in the Roming folder. If I didn't have hidden folders turned on we never would have found it.
C:\Users\me\AppData\Roaming\npm;
Then npm works from Node.js command prompt, and bower works from GitBash.
Check if C:\Program Files (x86)\Git\local is added to your Path Environment Variable.
Check your version of node, I was running on v0.10.15 then updated to v0.10.35 and that fixed the issue for me.

Windows: Unable to find "grunt.js" config file

Under Windows, I am getting the following error when I run grunt on my project:
Unable to find "grunt.js" config file. Do you need any --help?
I have exactly the same configuration as my mac and its failing - anyone seen this?
Here's what I did to fix this:
Uninstalled grunt globally:
npm uninstall -g grunt
Installed grunt-cli globally:
npm install -g grunt-cli
Then, in project root dir:
npm install
And all is good. Hope this works for anyone else running into this.