Node Modules not Found Even Environment is Configured - node.js

I am installing nodeJS v10 in Windows 10 Pro, After downloading the installer and install, I can run npm and npx to install the node modules but the installed global command cannot be found. I also try to use back npm install -g, but the error stays the same. Saying react-create-app, I can see it is being installed in the specified directory, but it always report command not found.
Command not found
npm config get prefix
Actual directory
Environment variable settings
User Variables
System Variables
As the environment variable seems setting up correctly, it is so weird for not finding the command. Any help would be appreciated, thank you very much

Related

"No version is set for command npm" .tool-versions file missing

I'm attempting to create my react app in VS code. After installing node.js (V 18.12.1), I ran the code to create my app and recieved the following response:
npm create-react-app example
No version is set for command npm Consider adding one of the following versions in your config file at nodejs 16.15.0 nodejs 16.17.0 nodejs 16.17.1 nodejs 16.18.0 nodejs 16.18.1
I attempted the reinstall node.js and believe the issue may be due to the absence of my .tools-version file, but I don't know how to create it.
You can use this
npx create-react-app example
Can see the detail in official document.
This could be because you are using a version of Node.js that does not include the npm command. In this case, you can try installing the npm command by running the following command:
npm install -g npm
or try these.
Verify that Node.js is installed correctly on your system by running the node -v command in a terminal. This should print the version number of Node.js if it is installed correctly.
Check if the npm command is in your system's PATH by running the
which npm command in a terminal. This should print the full path to the npm executable if it is in your PATH.
If npm is not in your PATH, you can add it by modifying your PATH
environment variable. You can do this by modifying your shell's
profile file (e.g., ~/.bashrc, ~/.bash_profile, etc.), or by adding the path to the npm executable to your PATH manually.
If you have multiple versions of Node.js or npm installed on your
system, you may need to update your PATH to point to the correct
version. Alternatively, you can use a version manager such as nvm
(Node Version Manager) to manage multiple versions of Node.js and
npm on your system.
Try out and see!
Came here searching a very similar error. I had just got setup with a version manager, asdf, and installed NodeJS LTS (asdf install nodejs lts) before running an npx command and getting the error below.
No version is set for command npx
Consider adding one of the following versions in your config file at
nodejs 18.12.1
nodejs lts
There's no path at the end of that second line 🤔 but given the error and asdf instructions on setting a version, I configured a NodeJS version in the global .tool-versions file and that solved my issued:
echo "nodejs lts" >> $HOME/.tool-versions
Manu Jo Varghese has some great suggestions for checking your installation and environment! To add:
which node: find NodeJS program in your path
bash or zsh -> check which shell you're in, then check .bashrc or .zshrc files as fits

'npm install -g typescript' doesn't install correctly on windows (missing tsc.cmd)

Global install of typescript doesn't appear to install correctly on windows.
Steps to reproduce:
.Using node v16.16.0 (64bit)
.Then 'npm install -g typescript'
.I can confirm environment path variables contain:
'C:\Users{MyUserName}\AppData\Roaming\npm' and
'C:\Program Files\nodejs\node_modules'
The node_modules/typescript/bin folder appears a follows:
As seen, a tsc file does exist, however the expected tsc.cmd doesn't.
This is required for windows to execute.
My assumption is this must be system or permissions problem whereby node can't create the tsc.cmd, not necessarily and issue with the
typescript package
Image for reference:
//----------------
Additional notes:
I have also tested this on 10.24.1 using nvm, this is now uninstalled
I have ran these steps on another machine, without problems countless
times.
I have uninstalled (completely) nvm and node before attempting this
multiple times.
I have performed a complete system search for tsc.cmd I do have
wsl installed, perhaps there is some interference there?
Results from suggestions this far:
Running locally on a project (Niceman)
I think this is an issue more related to your node path in your environment variables. To test this, install something else globally, like sass for example.
Then you can try sass --version. If it doesn't work the it's probably that your node path is messed up. You can try uninstalling node and reinstall it with the last LTS installing file from the official site. Then you can try to installing typescript again. If that doesn't work you'll need to open the environment variables and check your path for node modules.
Another possible solution is to try using another command line, because maybe a Powershell config is messing up this things. You can try installing git bash. It's not the best, but works.
Solution: use yarn!
As mentioned, I am missing tsc.cmd whatever method I choose (win 11). Who knows what the cause is.
By using yarn :
Delete the dudd folder under your node_modules folder from any npm attempts
yarn global remove typescript
yarn global add typescript
add 'C:\Users{yourUserName}\AppData\Local\Yarn\Data\global\node_modules.bin' to your path
As mentiond, you now have the required tsc.cmd:
What a ride ey!

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

PhpStorm/WebStorm terminal shows old NPM version

I am on Windows 10 x64 running PhpStorm 2018.3. I have updated NodeJS to 10.14.1 which includes NPM 6.4.1.
The Windows command line tool shows the correct versions
PhpStorm settings show the correct versions
The problem I have is that the PhpStorm terminal still shows NPM 3.10.10 although it shows the correct Node version.
I have tried:
Restarting PhpStorm
Restarting the computer
Uninstalling and re-installing Node, then restarting the computer
This causes trouble because the version of NPM running in my IDE terminal cannot see the globally installed packages.
Global packages from Windows command line
Global packages from PhpStorm terminal
How do I get to the bottom of this?
Update
Running where npm from the PhpStorm terminal shows that a local dependency has installed the older NPM version
Is it expected for a locally installed NPM to make it impossible for the terminal to see my global packages?
Update 2
When I run the Windows command line tool from within the project folder, everything works as expected, unlike the PhpStorm terminal. The right version is seen, global packages are seen, and the where command cannot see the local NPM installed in node_modules
Resolution
Thanks to Lena for the solution. Turns out that with PhpStorm 2018.3, a new enabled-by-default setting adds the binaries in the project's local ./node_modules/.bin to $PATH, so the terminal would see the locally installed NPM version instead of the global one. To resolve the issue I went to Settings > Tools > Terminal and unchecked this option:
Add node_modules/.bin from the project root to %PATH%
If anyone involved is reading this, I would suggest allowing the user to add a blacklist of binaries that should not be added when this option is checked.
The problem is caused by Add 'node_modules/.bin' from the project root to $PATH (Settings | Tools | Terminal) - as you have npm binary in node_modules/.bin, it's also added to %PATH% and thus used when running npm in terminal. Disabling this option should solve the issue

Node express command not found

i have used npm install -g express.
then used npm install -g express-generator
but when after install , i type express-V still told me :-bash: express: command not found.
please help me how to figure out this problem
You Say "Bash" that mean that you are running under linux or something similar. If a command could not be found from the system, it is not in in the Path environment variable. Check your NPM installation regarding environment variables. You need to include the global modules folder of npm in your Path.
Thanks for your answer.i reset the path environment and then it has been figured out.

Resources