How to install node.js in a custom directory through powershell? - node.js

I am making a script to install NodeJS on several machines through PowerShell.
By default NodeJS gets installed in C:\Program Files\nodejs folder. Can I define a custom directory for the installation?
I am running this command:
msiexec.exe /i $nodejs_download_filename /L*V "logger.log" /passive | out-null
Is there any argument to add to this line in order to specify the target directory instead of the default one?

You can refer this
Install Node.js on a different hard drive from C to D
You can move the node.exe to the d drive. Then check your environment path.
Type set in a command window or in computer properties.
Make sure you have the folder that contains node.exe in your path.
Running node in a command window will work from any folder then.
For installed npm packages, ie.. node_modules folder..
That just needs to be in a directory above where your writing your code, so try putting that folder in d:\ Assuming your going to be writing your apps on the d drive now.
In .npmrc file, change prefix setting to desired folder. Global packages get installed in node_modules under that folder.

Related

clasp is not recognized after installing on windows 10

I am trying to use Visual Studio Code as Google Sheets Script editor on a win 10 machine.
To make a long story short I will not describe all my steps, as I didn't really understood at the beginning exactly what I need. I also wouldn't be able to do it even I want to.
The current situation is that clasp is not recognized on the system.
These are command line results:
c:\>where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
c:\>where clasp
C:\Users\XXX\AppData\Roaming\npm\clasp
C:\Users\XXX\AppData\Roaming\npm\clasp.cmd
on drive c: root (and any folder other than C:\Users\XXX\AppData\Roaming\npm\clasp) clasp is not recognized
c:\>clasp -v
'clasp' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\XXX\AppData\Roaming\npm>clasp -v
2.3.0
One suggestion I found is setting Windows user variable as follows:
SET NODE_PATH=% APPDATA%\npm
Didn't help.
npm related paths on Windows PATH :
C:\Users\XXX\AppData\Roaming\npm
I tried to add to PATH the following file path before the one above
C:\Program Files\nodejs\npm
Didn't help
Based on this post looks like npm is actually installed twice. For current user C:\Users\XXX\AppData\Roaming\npm and for all users C:\Program Files\nodejs\npm.
Maybe this is the problem.
I would like to start over from clean env.
How can I uninstall the local user npm installation on C:\Users\XXX\AppData\Roaming\npm?
You need to add path to npm in environment variables. Then it will work.
Press Ctrl+r
Write %AppData% and hit enter
You will land on roaming folder
Go to npm folder inside roaming and check if a file named clasp is there or not
If yes, then add the path to npm in environment variables
In my case the path is C:\Users\HARI\AppData\Roaming\npm

How to run Node.js after downloading binary version for Windows

If I downloaded Windows Binary version (.zip, node-v8.11.4-win-x64) from nodejs.org and unpack the ZIP, what the next should I do? I'm newbie in NodeJS and can't find the answer in the docs
I see the file node.exe inside of unpacked folder and as I know it's so-called "repl".
Where should I create the working folder for the projects and the file hello-world.js?
And in which Windows' terminal can I run the commands?
Windows 7 Home Premium 64-bit
You should put node.exe on your system PATH, that way you can use it from any directory. Here's a guide to edit path on Windows 7:
http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx
You can then start it in any CMD shell or in PowerShell.
To test, start a new CMD window, and type
node -v
This should give you the node version.
I'd suggest you create something like a Projects directory for your code in your \user dir, with a subdirectory per project.
Once you've all this in place, just navigate to your project dir in your chosen shell and :
node hello-world.js

How to remove entire files and folders created for the nodejs and npm installation

I don't know what happend. All of a sudden, my nodeJS and npm started not responding and many errors popup and i reinstalled many times and not yet that works. When one problem solves, another rises. So i want to clean enitre setup files including in registery and other areas. Please someone help me.so i can reinstall node and npm.
To remove node from your window follow below instructions
1- Uninstall node from Programs & Features with the uninstaller.
2- Remove all the shortcuts like on task managers/ desktop etc
3-Reboot your system
4-Remove all the folder given below
C:\Program Files (x86)\Nodejs
C:\Program Files\Nodejs
C:\Users\{User}\AppData\Roaming\npm (or %appdata%\npm)
C:\Users\{User}\AppData\Roaming\npm-cache (or %appdata%\npm-cache)
C:\Users\{User}\.npmrc (and possibly check for that without the . prefix too)
5-Remove from the environment variable via checking Path value
6-Open your command prompt try to run below command
where node
If it will show directories then delete all the directories
7-Reboot your system
8-Go to the node js side download or directly install the node from there.

How to install Node.js on Windows 10?

I tried to install Node.js on the Windows 10 64 bit using installer.
When I run installe.exe I accept rules and push next button, in any case I get the following notification:
When I tried to set path of downloaded install file:
And get this error again.
#Babaev From what you said, I guess its a problem related to path issue or rather the .msi file may have been corrupted on download. Try the windows binary that is .exe file from https://nodejs.org/en/download/ let's say we have the node.exe file located in the folder c:\nodejs. Now to setup npm-
Step 1: Download the latest npm release from
GitHub(https://github.com/npm/npm/releases) Step 2:Create folders
c:\nodejs\node_modules and :\nodejs\node_modules\npm
Step 3:Unzip the
downloaded zip file in c:\nodejs\node_modules\npm folder
Step 4:Copy
npm and npm.cmd files from c:\nodejs\node_modules\npm\bin to c:\nodejs
folder.
Step 5: As the final step you can add node's folder
pathc:\nodejs to the path environment variable so that you don't have
to specify full path when running node.exe and npm at command prompt.
Hope this helps :)

Install Node.js on a different hard drive from C to D

I have node and npm with existing packages currently installed to the C drive on Windows. My C drive is an SSD with a low amount of space. How can I move the node installation to a different drive? Would I need to reinstall node and all packages? The current node installer doesn't seem to specify drives.
You can move the node.exe to the d drive. Then check your environment path. Type set in a command window or in computer properties. Make sure you have the folder that contains node.exe in your path. Running node in a command window will work from any folder then.
For installed npm packages, ie.. node_modules folder.. That just needs to be in a directory above where your writing your code, so try putting that folder in d:\ Assuming your going to be writing your apps on the d drive now.
In .npmrc file, change prefix setting to desired folder. Global packages get installed in node_modules under that folder
I'm not sure what you are talking about, the node installer has this page.
What version of node are you trying to install? This screenshot is taken from v0.11.7 of node.
I know this post was basically forever ago, but I found a much easier way than manipulating the path. Simply uninstall NPM using the npm uninstaller, reinstall on your other drive with a new folder called nodejs. It'll create the folder in there appropriately and npm will be successfully installed on you D drive.
Search -> Environmental variables of system
click on path ( both )
click on new
add the path of your node.exe file
boom you are done*
node -v to check

Resources