For me, it was much easier to do this in Powershell.
$env:Path += ";C:\Program Files\nodejs\"
Ran "npm" in powershell, and came up straight away.
Answer from HelpfulStranger on Stack Overflownode.js - npm install doesn't work in Windows PowerShell - Stack Overflow
NPM not recognized in Powershell or Command Prompt
node.js - How to install nodejs and npm on windows using command lines - Stack Overflow
NPM NOT WORKING ON WINDOWS AFTER INSTALL AND REBOOT
Videos
For me, it was much easier to do this in Powershell.
$env:Path += ";C:\Program Files\nodejs\"
Ran "npm" in powershell, and came up straight away.
Use .npmrc to set the prefix explicitly:
Go to
\Users\%USERNAME%\.npmrc. For example, in Powershell:Notepad "\Users\$env:USERNAME\.npmrc"Set the prefix:
prefix = "C:/Program Files/nodejs"
References
- Is there a manual install of node.js for Windows 7?
- Opening a program with PowerShell from a shortcut
- nodeJS Modules: Loading from the Global Folders
- npm config Readme
- npm Folders: prefix configuration
- nodejs source: legacy-npm-self-install.js
- forward slash usage
You can install using this msiexec, select the version that's most suitable for you in the link
msiexec.exe /a https://nodejs.org/dist/v8.3.0/node-v8.3.0-x64.msi /quiet
I was running in the ServerCore windows container on Gitlab so the msiexec.exe did not work for me. However found another answer that did work over here from user Witcher: Docker + Node.js + Windows
The commands in the container that ended up working in my gitlab yml file before_script were:
Invoke-WebRequest 'https://nodejs.org/dist/v18.12.0/node-v18.12.0-win-x64.zip' OutFile 'C:/nodejs.zip'
Expand-Archive C:\nodejs.zip -DestinationPath C:\
Rename-Item "C:\\node-v18.12.0-win-x64" C:\nodejs
$Env:Path += ";C:\nodejs"
This is downloading the Zip file from Nodejs's site to the root of C, expanding the archive, and setting the nodejs path to the environment path variable so the "npm" command is recognized.
Hello, i installed nodejs, added to path on windows and all, but it dosent seem to work. Using it on windows terminal gives me this error.
npm : File C:\Program Files\nodejs\npm.ps1 cannot be loaded because running scripts is disabled on this system. For
more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ npm
+ ~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Maybe this isnt the subredit for the question, but i need help. I would be glad with your help.
OS: Windows 11 Home
Why is it so damn impossible to install node and npm properly? I just don't get it. I've downloaded the latest stable node release, installed it, and added to path. The npm and node commands are recognized in the terminal. It just works in macOS, it just doesn't f-ing work in Windows. All I get is this stupid error over and over again. I've tried to reinstall openssl, and tried updating node and npm aswell. Every single guide out of the thousands available online simply puts it this way:
Download node installer
Run installer, double check path
Enjoy!
Both my Ubuntu machine and Windows machine gets a stroke when I try to simply start up my React project... And as I said earlier, installing node and running npm start in macOS works just fine...
How hard can it be to make a product that simply installs everything it needs and runs perfectly every time? It's not like users are tampering with the installation process...