How to install Node Version Manager(NVM) without admin rights - node.js

I have no admin rights in my windows machine. Can I install NVM without admin rights? I tried using the environment variable path setup, but its not working in my case.

I have the same need and couldn't find one, so I created one base on another simple nvm:
https://www.npmjs.com/package/#jchip/nvm
Requires powershell 4+ and permission to execute scripts.

(You're talking about https://github.com/coreybutler/nvm-windows right?)
Whether you can install it without admin rights aside, the actual act of switching node versions with it requires them so you're going to have trouble.
Your best bet is to install different versions of node into different paths manually, and then configure your environment variables to point to the right one whenever you need to use it.
eg. prefix your cmd script with PATH=C:\node\v10;%PATH% to have any node or npm calls in that script use whatever node is sitting in v10

try this
create a bat file like below
#cd C:\Users\testuser\AppData\Roaming\nvm
#SET PATH=C:\Users\testuser\AppData\Roaming\nvm\v14.21.1;%PATH%
cd c:\users\testuser\Desktop\Project
#cmd.exe /K
Run bat file and type
code .
It's open with VSCode
go to the terminal and type node and you can see the node version that you set in the bat file.
enter image description here
You can apply any node version as above bat file

If you use Git Bash on Windows, you can add this to your bash.bashrc to switch node versions:
export PATH=/c/path/to/node/dir:$PATH
Then just restart your terminal to pick up the updated PATH.
It will prepend your path with your desired node version. It's the only way I've found to override the installed node version if you don't have admin rights on your machine.

Related

command prompt when i try install any dependence

when I try to install any dependence in command prompt get this error message and tried to google but nothing any one to help me please
please I need help someone to help me
try installing locally. and add this path to your system variable: C:\Program Files\nodejs
Reinstall the node.
You have two ways to install Node.js on your computer.
Option 1 – Setup by running the .msi installation file
Its a typical Windows installation and automated. No need to add
entries in environment varaiable
Option 2 – Setup by extracting .zip file
This method does not require admin access and can be used to install
on nodejs on a system on which you dont have admin access such as you
official laptop or desktop.
Removing nodejs is as simple as deleting the folder. You will have
to add entries in environment variable if you want to execute node
command from any location in windows command prompt. https://nodejs.org/en/download/
Based on the screenshot.your access is denied.Would suggest starting the terminal as an administrator before running the command.

npm run build on windows 10 gives This app can't run on your PC

Trying to run the command npm run build on my system but keep getting this
error. Tried uninstalling node but no luck. Any pointers would be helpful
The issue for me was that I am using nvm, and for reasons I don't yet know, when I try to set my node version to 12.14.0, and then run nvm list, no versions are selected. I went back to 13.8.0 and nvm list showed that 13.8.0 was selected.
Long story short, make sure you have a selected node version.
you should follow one of two option:
Option 1 – Setup by running the .msi installation file
Its a typical Windows installation and automated.
No need to add entries in environment varaiable
Option 2 – Setup by extracting .zip file
This method does not require admin access and can be used to install on nodejs on a system on which you dont have admin access such as you official laptop or desktop.
Removing nodejs is as simple as deleting the folder.
You will have to add entries in environment variable if you want to execute node command from any location in windows command prompt.
See the link below for more details : install Node.js and NPM on Windows 10

Can't run npm or any Node Module on Cmder (Windows 7)

I simply can't run "npm" or, for instance, "gulp" in my cmder. But I can run it if I manually open the cmd
λ gulp
'gulp' is not recognized as an internal or external command,
operable program or batch file.
If I run npm manually from the Nodejs directory, it works. So I added an alias with alias npm=C:\Progra~1\nodejs\npm.cmd $* and now npm works, but I guess that's not the best solution, since I can't run Node modules.
What I've tried
I've tried to add "%APPDATA%\npm\node_modules" and
"AppData\Roaming\npm" to both System and User environment variables
Restarting the computer
Running cmd as admin inside of Cmder
Add "%APPDATA%\npm\node_modules" and "AppData\Roaming\npm" to
"Cmder's user-startup.cmd" path.
I can run Ruby's gem or Python inside of cmder just fine, but Node just won't work specifically inside of Cmder (but will work on window's native cmd.exe)
Fixed
Download the lastest version of Cmder through the github repo https://github.com/cmderdev/ instead of downloading it from the website.
Add the "C:\Progra~1\nodejs\" to your user path in Windows using the System Properties window. Restart Cmder. Cmder can then see all the nodejs related executables, including npm.
The standard release from the website will work.
source: this has worked for me.
Run cmder as admin..
The reason why the workaround (moving files in the same directory) works is because running the cmder does not have privileges to access files outside of its directory. So either give it orivelages or Run as Admin. That it expands da the paths it can access and removes limitations/restrictions.
problem solved
For me what worked was using the cmder from selecting save file instead of open with Windows Explorer (default)
Briefly:
Create shortcuts for npm.cmd and npx.cmd and put them to ../cmder/bin/ folder.
Detailed:
Install nodejs. For example, to C:/Program Files/nodejs
Install cmder. For example, to C:/cmder
Go to nodejs folder and create shortcuts for npm.cmd and npx.cmd (right click - create shortcut). Windows will show message that cannot create here, will be created on Desktop instead - agree.
Copy shortcuts from Desktop to /cmder/bin/.
Rename them to npm.cmd and npx.cmd relatively (remove - Shortcut).
Reopen cmder, run npm.

Fixing npm path in Windows 8 and 10

Have done a lot of googling, tried reinstalling node.js using the official installer, but my npm pathing still doesn't work.
This doesn't work
npm install foo
I get an error message saying missing module npm-cli.js
2 hours of googling later I discovered a workaround
Instead of simply 'npm' I type
node C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
But how can I correct my nodejs install so I can simply type 'npm' ?
You need to Add C:\Program Files\nodejs to your PATH environment variable. To do this follow these steps:
Use the global Search Charm to search "Environment Variables"
Click "Edit system environment variables"
Click "Environment Variables" in the dialog.
In the "System Variables" box, search for Path and edit it to include C:\Program Files\nodejs. Make sure it is separated from any other paths by a ;.
You will have to restart any currently-opened command prompts before it will take effect.
get the path from npm:
npm config get prefix
and just as a future reference, this is the path I added in Windows 10:
C:\Users\{yourName}\AppData\Roaming\npm
Update:
If you want to add it for all users just add the following path [by #glenn-lawrence from the comments]:
%AppData%\npm
I have used the cmdlet and navigate to the path you want to switch your npm files to. Type in npm root -g to see what the current path your npm is installed to. Next use npm config set prefix and your npm path will be changed to whatever directory you are currently on.
Try this one dude if you're using windows:
1.) Search environment variables at your start menu's search box.
2.) Click it then go to Environment Variables...
3.) Click PATH, click Edit
4.) Click New and try to copy and paste this: C:\Program Files\nodejs\node_modules\npm\bin
If you got an error. Do the number 4.) Click New, then browse the bin folder
You may also Visit this link for more info.
Go to control panel -> System -> Advanced System Settings then environment variables.
From here find the path variable, Go to the end of the line and paste "C:\Program Files\nodejs\node_modules\npm\bin" (change the path to the directory to where ever you installed it e.g. if you specifically installed it anywhere change it)
Edit the System environment variables, and enter following path:
C:\Program Files\nodejs\node.exe;
C:\Users\{yourName}\AppData\Roaming\npm
Installed Node Version Manager (NVM) for Windows: https://github.com/coreybutler/nvm-windows
I'm using Windows 10 - 64 bit so I run...
Commands:
nvm arch 64 (to make default the 64 bit executable)
nvm list (to list all available node versions)
nvm install 8.0.0 (to download node version 8.0.0 - you can pick any)
nvm use 8.0.0 (to use that specific version)
In my case I had to just switch to version 8.5.0 and then switch back again to 8.0.0 and it was fixed.
Apparently NVM sets the PATH variables whenever you do that switch.
You can follow the following steps:
Search environment variables from start menu's search box.
Click it then go to Environment Variables
Click PATH
click Edit
Click New and try to copy and paste your path for 'bin' folder [find where you installed the node] for example according to my machine 'C:\Program Files\nodejs\node_modules\npm\bin'
If you got any error. try the another step:
Click New, then browse for the 'bin' folder
If after installing your npm successfully, and you want to install VueJS then this is what you should do
after running the following command (as Admin)
npm install --global vue-cli
It will place the vue.cmd in the following directory
C:\Users\YourUserName\AppData\Roaming\npm
you will see this in your directory.
Now to use vue as a command in cmd. Open the cmd as admin and run the following command.
setx /M path "%path%;%appdata%\npm"
Now restart the cmd and run the vue again. It should work just fine, and then you can begin to develop with VueJS.
I hope this helps.
This worked for me:
1. npm root -g (to see the current npm is installed)
2. npm config set prefix (to change the path)
I did this in Windows 10,
Search for Environment Variables in the Windows search
"Edit the System environment variables" option will be popped in the result
Open that, select the "Path" and click on edit, then click "New" add your nodeJS Bin path i.e in my machine its installed in c:\programfiles\nodejs\node_modules\npm\bin
Once you added click "Ok" then close
Now you can write your command in prompt or powershell.
If you using WIndows 10, go for powershell its a rich UI
change the path for nodejs in environment varibale.
add Environment Path to
C:\Program Files\nodejs\node.exe;C:\Users[your username]\AppData\Roaming\npm
steps 1
in the user variable and system variable
C:\Program Files\nodejs
then check both node -v
and the npm -v
then try to update the the npm i -g npm
I've had this issue in 2 computers in my house using Windows 10 each.
The problem began when i had to change few Environmental variables for projects that I've been working on Visual studio 2017 etc.
After few months coming back to using node js and npm I had this issue again and non of the solutions above helped.
I saw Sean's comment on Yar's solution and i mixed both solutions:
1) at the environmental variables window i had one extra variable that held this value: %APPDATA%\npm. I deleted it and the problem dissapeared!
If you can't work with npm packages, you propably has bad config with npm install packages, you try this:
Run the following command in your terminal to revert back to the default registry
npm config set registry https://registry.npmjs.org/
https://docs.npmjs.com/misc/config#registry
When you're on Windows but running VS Code in Windows Subsystem for Linux like this
linux#user: /home$ code .
you actually want to install NodeJs on Linux with
linux#user: /home$ sudo apt install nodejs
Installing NodeJs on Windows, modifying PATH and restarting will get you no results.
If, like me, you have MSYS_NO_PATHCONV = 1 configured as a user variable for Git Bash, this issue will be triggered. To workaround, you can either remove this variable or use a different shell (PowerShell) for npm.
I did Node repair with the .msi file and everything worked well.
I may be a total noob but I had no clue I had to install npm-cli first. I had just assumed I already had it.
npm install --global vue-cli

Node.JS - How to Run Node Command from any path?

I have installed the latest node.js from here . I see the %Path% variables have been set for Node.js. But, When i run node from C:\ , i get a "Node is not an recognized comman". But node command is working fine from "C:\Program Files (x86)\nodejs" path. Can i not run Node commands from C:\ or Say from an other path if i set the Env variables right? Please help. I am running a Win7 X64.
Thank You,
Faraaz
I had the exact same problem, but in my PATH variable I had: C:\Program Files\nodejs\.
After changing it to C:\Program Files\nodejs I could access it from anywhere.
What happens if you run node --version? I have never tried node.js from windows but if that doesn't work there is something wrong with your paths.
What do you get when you run echo %PATH%?
You should check if the path C:\Program Files (x86)\nodejs is present in your %PATH. If not, add it via the system properties (persistent change). In any case, restart your command prompt, it'll reload the %PATH variable. If you're lucky, it should work now :)
Most likely it happens because there is no Node path in your PATH environment variable.
I see two ways to solve this
Just add Node path into the end of PATH.
Reinstall Node as administrator
run 7-zip (or some file manager) with administrator privileges >>
browse to node-installer.msi >> open it, install node >> enjoy
My Sublime was working with Nodejs fine. I could press Alt-R and see the output from Node in Sublime. Then at some point I upgraded Sublime. I now have version 2.02 build 2221
And at some later point I tried Alt-R and got this infamous message
'node' is not recognized as an internal or external command
But it had worked, so what changed?
The steps I took to fix it were to install git bash and then
$ git clone https://github.com/tanepiper/SublimeText-Nodejs.git
$ cd SublimeText-Nodejs/
$ git checkout 095ba03344
Back in Sublime I clicked Preferences > Browse Packages. This opened up Windows Explorer with the folder:
C:\Users\me\AppData\Roaming\Sublime Text 2\Packages
I replaced the contents of the Nodejs folder with the git version. Re-started Sublime and then Alt-R sprang back into life.
Other things that turned out to be irrelevant were changing the file Nodejs.sublime-settings and tampering with system environment variables. The only thing that worked was 095ba03344 as described here
https://github.com/tanepiper/SublimeText-Nodejs/pull/39

Resources