How to install nodejs and npm on windows using command lines - node.js

I am creating a package installer which has nodejs, redis, and socket.io as prerequisites. The problem is that I don't want the developers to install the prerequisites own their own.
I figured out a way of doing that using on mac and ubuntu by including brew install node for mac
and sudo apt-get install nodejs, sudo apt-get install npm
I am now looking for a way to install nodejs on window using a command or two.
Any Idea? Please.

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

Nodejs Alternative For Windows
Using Chocolatey:
cinst nodejs
or for full install with npm
cinst nodejs.install
Using Scoop:
scoop install nodejs

You could use:
cinst nodejs.install
This is great install with npm.

Install nodejs version 8.10.0 on window
download the installer from the url given below
https://nodejs.org/download/release/v8.10.0/
download .mis file from this page
you can download all versions form this url just by changing version number in the end of url
2.Install Angular 6 on window
Open command line as administrator
run below command in command line
npm install -g #angular/cli#6

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.

Related

Npm not working (openSSL configuration error windows10x64)

I was getting this error whenever I try the npm command in powershell:
**~ $ node -v
v17.1.0
~ $ npm -v
OpenSSL configuration error:
74240000:error:80000003:system library:BIO_new_file:No such process:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:67:calling fopen(C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf, rb)
74240000:error:10000080:BIO routines:BIO_new_file:no such file:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:75:
74240000:error:07000072:configuration file routines:def_load:no such file:c:\ws\deps\openssl\openssl\crypto\conf\conf_def.c:179:
OpenSSL configuration error:
A8250000:error:80000003:system library:BIO_new_file:No such process:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:67:calling fopen(C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf, rb)
A8250000:error:10000080:BIO routines:BIO_new_file:no such file:c:\ws\deps\openssl\openssl\crypto\bio\bss_file.c:75:
A8250000:error:07000072:configuration file routines:def_load:no such file:c:\ws\deps\openssl\openssl\crypto\conf\conf_def.c:179:**
Another thing I noticed is that the node must have updated incorrectly because even though it gives me a version, I cannot uninstall it and cannot find the install files in my program files. I am at a total loss and about to just reset my computer to default. I want to repair it but everything online tells me to use npm, which in itself is not possible.
I have tried using the "set OpenSSL" command to empty or to a dummy file but it does not seem to do anything.
Go to the Windows control panel and click on Uninstall a program, select Node.js and click on the uninstall tab to uninstall the node and npm successfully. Restart your system.
Then go to https://nodejs.org/en/ to download 16.13.0 LTS version and install it
Please check environment path using PowerShell
check environment path:
cmd /c echo %PATH%' or 'cmd /c echo %OPENSSL_CONF%
You will get C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf path so reset the environment path for openssl using below comment on PowerShell
set OPENSSL_CONF=''
after that, the problem will be fixed.
this issue already issued on Nodejs GitHub.
https://github.com/nodejs/node/issues/40547
the only thing that you're to do is to create a new archive called openssl.cnf
in this route:
C:\Program Files\PostgreSQL\psqlODBC\etc\openssl.cnf
Save the work and run in cmd: npm --version
Had this issue in a conda environment. Fixed by installing node with next command: conda install -c conda-forge nodejs=16.3.2
Try to uninstall the node from your project directory.
npm uninstall node
Most probably you have 2 different versions of Node installed on your system.
If my solution does not work for you. Try the other suggestions with uninstalling Node from the system.
My solution was to use another node version in this case 15.8.0, you can try with others most recently versions. When I did this npm was installed correctly:

loopback "lb4" command is not working after successfully installation of loopback CLI using "npm i -g #loopback/cli"

I have successfully installed loopback CLI using npm i -g #loopback/cli after that I'm trying to create app using lb4 app command terminal and it shows me Command 'lb4' not found.
Only lb app works for version 3 and 2 but I want to create application compatible with loopback version 4.
I had the same problem and solved it by updating to the latest version of Node.js (10.7 as of now). Then I reinstalled the LoopBack CLI with npm i -g #loopback/cli and the lb4 app command worked just fine. Also, I was executing all the commands as admin, in case it helps.
If you're having trouble creating a global link on Windows 10 (like I did).
Consider installing in the NodeJS project folder as a work-around.
Simply execute:
npm install #looback/cli --no-save
Notes:
This will install the cli without listing it as a dependency in your package.json.
This will allow you to run lb4 app only in the root folder of project where you ran the command.
This solution is not ideal since you'll have to do this for each project. However I figured it beats having to install a new version of NodeJS just for the installer to clear some cache/configuration that got messed up over a long time-period.
Upgrade your Node.JS to version 8.9 or higher.
It's a Prerequisites.
See the doc: https://loopback.io/doc/en/lb4/Getting-started.html#prerequisites
Also some time npm installs the JS module successfully but does not add in environment variable. Find the npm folder path (in my case C:\Users\user_name\AppData\Roaming\npm) and add into class path. After adding environment variable restart the command prompt.
I was also facing same problem. But then I ran the command using sudo and it worked. sudo npm i -g #loopback/cli.
sudo update-alternatives --install /usr/bin/lb4 lb4 /opt/nodejs/node-v19.1.0/bin/lb4 0
This command will be more useful to solve this problem.
You can replace nodejs path according to your system.(/opt/nodejs/node-v19.1.0/bin)

Update Parse Server on Ubuntu

I have my own Parse server running on an Ubuntu droplet on Digital Ocean. I'm pretty new to running my own backend. How do I check what version of Parse Server I'm running and how do I update it to the latest version?
Open terminal (command line tool), then use "cd" command to navigate to your parse-server-example directory: cd ...../parse-server-example/
Pull latest source code from github with command: git pull
Install packages and dependencies: npm install
Run it: npm run index.js
If you want your server keep running you can install and use forever.
Good luck!
You can look into the package.json file of parse-server .
Or you can just use npm list to list all packages and their dependencies with version .

Why isn't Node Version Manager (NVM) recognized on Windows?

I am trying to downgrade my version of node
I ran:
npm install nvm
and I exported the bin folder to my Windows path variable,
C:\Program Files (x86)\nodejs\node_modules\npm\bin
but I still get:
'nvm' is not recognized as a an internal or external command.
Should I be adding another path to my path variable?
nvm was designed for Linux. nvmw, which is completely different, broke around node v0.10.30. Try NVM for Windows.
NVM can be used to manage various node version :
Step1: Download
NVM for Windows
Step2: Choose nvm-setup.zip
Step3: Unzip & click on installer.
Step4: Check if nvm properly installed, In new command prompt type nvm
Step5: Install node js using nvm :
nvm install <version> : The version can be a node.js version or "latest" for the latest stable version
Step6: check node version - node -v
Step7(Optional)If you want to install another version of node js - Use STEP 5 with different version.
Step8: Check list node js version - nvm list
Step9: If you want to use specific node version do - nvm use <version>
NVM Installation & usage on Windows
Below are the steps for NVM Installation on Windows:
NVM stands for node version manager, which will help to switch between node versions while also allowing to work with multiple npm versions.
Install nvm setup.
Use command nvm list to check list of installed node versions.
Example: Type nvm use 6.9.3 to switch versions.
For more info
As an node manager alternative you can use Volta from LinkedIn.
I created a universal nvm that works on both Unix (bash) and Windows, base on another simple nvm.
It doesn't need admin on Windows, but requires PowerShell 4+ and the right to execute scripts.
https://www.npmjs.com/package/#jchip/nvm#installation
The first thing that we need to do is install NVM.
Uninstall existing version of node since we won’t be using it anymore
Delete any existing nodejs installation directories. e.g. “C:\Program Files\nodejs”) that might remain. NVM’s generated symlink will not overwrite an existing (even empty) installation directory.
Delete the npm install directory at C:\Users[Your User]\AppData\Roaming\npm
We are now ready to install nvm. Download the installer from https://github.com/coreybutler/nvm/releases
To upgrade, run the new installer. It will safely overwrite the files it needs to update without touching your node.js installations. Make sure you use the same installation and symlink folder. If you originally installed to the default locations, you just need to click “next” on each window until it finishes.
Credits
Directly copied from : https://digitaldrummerj.me/windows-running-multiple-versions-of-node/
I will list two ways. You can choose one Whichever works for you.
1. Using installer
Download nvm-setup.zip and unzip the file and install it, keeping the configurations default.
1. Use curl
Copy the below command and run it in your terminal
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
After this reopen/open terminal and check the nvm version runing below command.
nvm -v
And that's it.
If someone is looking for install on Window 11! Not directly relevant here, but might be useful.
It is immaterial if you install NVM (version 1.1.9.) say after the node (16.15.1) is already installed. During the nvm installation process, it asks for the right to manage the existing node version and symlinks that.
Get the version from the GitHub repo, I opted for the zip version.
https://github.com/coreybutler/nvm-windows/releases
Double click the application and it is just a few steps.
1.downlad nvm
2.install chocolatey
3.change C:\Program Files\node to C:\Program Files\nodejsx
emphasized textThe first thing that we need to do is install NVM.
website :
https://learn.microsoft.com/en-us/windows/nodejs/setup-on-windows
So this answer is for windows users that are using git bash or some other console emulator like cmder ... if you're using CMD this solution will not work for you also why? why are you still using CMD?
I know this is a pretty old post but I just achieved this yesterday and wanted to add my answer for anyone looking to do the same.
First check if you have .bashrc profile in your home directory by typing ls -alh ~ (by default this doesn't exist)
if it doesn't exist type this command to generate a .bashrc profile with default values in it cat /etc/bash.bashrc > ~/.bashrc (if it does exist skip this step)
Download and run the nvm install script as provided in the nvm docs page curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash (make sure you do this in your home directory)
then edit the new generated .bashrc profile file you created above; use nano/vim to do that nano ~/.bashrc and add the following to the bottom of the file export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm and save your .bashrc file with the changes.
lastly source your .bashrc file by typing source ~/.bashrc
verify installation nvm --version
and now you have nvm installed and you can use the commands as per https://github.com/nvm-sh/nvm#usage
First off, I use nvm on linux machine.
When looking at the documentation for nvm at https://www.npmjs.org/package/nvm, it recommendations that you install nvm globally using the -g switch.
npm install -g nvm
Also there is a . in the path variable that they recommend.
export PATH=./node_modules/.bin:$PATH
so maybe your path should be
C:\Program Files (x86)\nodejs\node_modules\npm\\.bin
An alternative to nvm-windows, which is mentioned in other answers would be Nodist.
I've had some issues with nvm-windows and admin privileges, which Nodist doesn't seem to have.
I know I'm late here but this may help in the future if someone looking for NVM to install in Windows or linux
run this command in cmd
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

Building syntaxhightlighter with nodejs in windows 7

I need to build Syntaxhighlighter from here: https://github.com/alexgorbatchev/SyntaxHighlighter
I have read these:
https://npmjs.org/doc/faq.html
Getting started with NODE.JS in windows x86
Get started with Node.js in Windows
Installing node packages / dependencies using npm on Windows Server 2008
It seems that installing Nodejs from here http://nodejs.org/download/ should be enough.
Step 3 in the syntaxhighlighter Building instructions says:
3.Then ./node_modules/.bin/bower install to download dependencies
I have this path on my machine:
C:\Program Files (x86)\nodejs\node_modules\npm\bin
and I can see a bower.json in the syntaxhighlighter zip file.
I have googled how to download dependencies for windows, but I cant find anything.
There is a lot of info here:
How do I get started with Node.js
but I think this is not for windows env.
Can you assist?
EDIT:
Ok, seems to work now.
Installed Git-1.8.4-preview20130916.exe and restarted.
Step 8 ok now.
Step 9 gives "grunt not recognized".
Tried
npm install -g grunt-cli
from here: https://github.com/gruntjs/grunt/issues/774
Now I have a pkg folder
Thank you sir
Install NodeJs for Windows per instructions
Install Git for Windows, select option to Add Git to your path.
Open a new command prompt in Windows. Ideally, open as an Administrator. Do not reuse existing command prompts. The path will only be set in a new command prompt properly.
Download the code for the highlighter or use git to clone
If you got the zip file, unzip it
From the command prompt, change the active directory to be the folder of the code you cloned or unzipped
Type npm install -g grunt-cli, then Enter after each of the following...
Type npm install -g bower
Type npm install
Type bower install
Type grunt build
Done.
You have to install git package in this way:
sudo apt-get install git
It's working fine!

Resources