npm init script doesnt operate. How to fix it? - node.js

I am trying to create a new node.js project and want to create package.json file, i am a windows user and trying to crete my project on Visual Studio Code terminal. When i type npm init i get the following error :
npm : The term 'npm' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the
name, or if a path was include d, verify that the path is correct and
try again. At line:1 char:1
npm init
+ CategoryInfo : ObjectNotFound: (npm:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
How can i make it recognized? Thanks in advance

Go to your path settings in Windows and add the directory of node at the end of it
;C:\Program Files\nodejs\
Also you can find more informatin in this thread:
'npm' is not recognized as internal or external command, operable program or batch file

Related

How to run 'npx create-react-app' command successfully in VS Code terminal on Windows 10?

I am trying to create a MERN-based tinder app but faced error in the very first command. When I ran 'npx create-react-app tinder' in VS code terminal, I got this error message -
npx : The term 'npx' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ npx create-react-app tinder
+ ~~~
+ CategoryInfo : ObjectNotFound: (npx:String) [], CommandNotFoundException
I have Node.js installed on my system. Below are two things I have tried, but they didn't work.
I tried running node -v in VS Code terminal to check if VS Code is able to recognize Node.js. But on running this command, I got the following error message:
node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ node -v
+ ~~~~
+ CategoryInfo : ObjectNotFound: (node:String) [], CommandNotFoundException
Note that on running version commands for Node and NPM on Windows PowerShell and command prompt, I am able to see their versions as output (v16.18.0 and 8.19.2 respectively) confirming their presence in my system.
Nonetheless, I tried running npm install -g create-react-app command in VS Code terminal next and the following is what I got:
npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ npm install -g create-react-app
+ ~~~
+ CategoryInfo : ObjectNotFound: (npm:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I suspect that this problem may be due to some path setting that I need to do correctly. My folder named 'tinder' and Node.js are in different drives (Tinder is in E drive and Node.js is installed in C drive). Is that the reason for error?

Visual studio code not recognising NPM

I wanted to make website. And I used Vite to do it (according to tutorial). However Visual studio code is not recognising npm commands (in console).
I have installed nod. js, and have it written in the path. Cmd is recognising npm, and it is giving me the version also.
Do you know where the problem could be?
My code:
PS C:\Users\451\Desktop\Web 3.0\client> npm init vite#latest
npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ npm init vite#latest
+ ~~~
+ CategoryInfo : ObjectNotFound: (npm:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Vite site - https://vitejs.dev
Okay so I solved the problem. I don´t know why, but when I used command npm -v and node -v inside my visual studio code console it seems to start working. Don´t know why, don´t know how. It just started to work.

Why does node.js not work in visual code?

I know this problem has been asked a few times, but I still couldn't find a correct answer for myself.
I have node.js installed in my 'C:\Program Files' folder, and I can run the node.js app.
When opening the command prompt I can also get the version of the node by typing 'node -v' which shows my node version v14.15.4.
But whenever I write this in VS Code terminal it shows me this error message:
node: The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
node
+ CategoryInfo : ObjectNotFound: (node:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

nexe : The term 'nexe' is not recognized as the name of a cmdlet, function, script file, or operable

We are facing the below problem when we are trying to build an exe via nexe command. This worked well on a development environment which is a Oracle VM, but on the server machine, this is happening. Nexe module is installed and I could see it in node_modules folder. Please let me know what could be missing.
PS <C:\Program Files\iisnode\www\tcnx>> nexe PLM_Adaptor.js --build
nexe : The term 'nexe' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ nexe PLM_Adaptor.js --build
+ ~~~~
+ CategoryInfo : ObjectNotFound: (nexe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Thanks,
Pavan.
npm i nexe -g
will install the nexe module in a path like this one:
C:\Users\your_username\AppData\Roaming\npm
it will also store a file named "nexe.cmd" in this folder. This is the file you actually execute when just typing "nexe" on the commandline.
In order to make this work, make sure nexe.cmd exists in the mentioned npm folder (or locate where it is) and make sure that this folde is in the PATH like so:
set PATH=%PATH%;C:\Users\your_username\AppData\Roaming\npm
npm i nexe -g
run this command and issue will be solved...

How to correctly configure Windows PATH environment variable for Node.js

I have installed globally the nodemon module (version 1.11.0).
The installation was successful and the package exists in the global modules list, but the nodemon command returns the following error in Powershell:
nodemon : The term 'nodemon' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ nodemon
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (nodemon:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
This happens when I try to run commands from other globally installed modules, so It seems there is a path error.
The user variable with name PATH has the value:
C:\Program Files\nodejs;C:\Users\Cal\AppData\Roaming\npm\node_modules;C:\Program Files\MongoDB\Server\3.4\bin
Is my diagnosis correct, and if so, where am I going wrong?

Resources