npm run build on windows 10 gives This app can't run on your PC - node.js

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

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 does not install any package Cannot read property 'version' of null

i'm using node v16.7.0 and npm v7.20.3. I bought new laptop(w10) and installed node but since that(almost a week), i couldn't start any node related project because i can not install any npm package. Whenever i try to 'npm install'
npm install <package>
I get the error:
npm ERR! Cannot read property 'version' of null
I dig into all around web to find a solution for this but i couldn't get one. Can someone help me with this issue this is my first question in Stackoverflow.Also if i use dual boot with Ubuntu or WSL2(Web Subsystem for Linux) will i get less errors with development tools even though i'm into web development nothing to do with kernel. Thanks...
Edit: I had spaces and non English character in my username folder in Windows so i tried changing my username and username folder and it solved my problem.(Note that changing username does not reflect to username folder you have to set extra configuration for that).
The error message means that npm is trying to read the version property of the folder's package.json file but doesn't find the file.
Check that you have a package.json file inside your folder, and see what's the value of the version property.
If you need to create a package.json file out of the box, run npm init and follow the instructions. For more information, view the npm documentation about npm init.
Also, make sure that you've installed Node correctly. It's recommended to use a Node version manager to manage your Node installations.
Also if i use dual boot with Ubuntu or WSL2(Web Subsystem for Linux)
will i get less errors with development tools even though i'm into web
development nothing to do with kernel
Yes, and dual-booting with Ubuntu would be best. Virtual machines can be slow and require additional configurations to improve performance, and a lot of issues are reported on WSL.
Most development tools work natively with Linux and therefore run better on Linux. Ultimately, it depends on what language you're developing with and what environment you're developing for.
In general, Linux will make your development experience much less of a hassle. Information, tutorials, and troubleshooting about those tools is also more easily available for Linux.
One of the best things about switching from Windows to Linux is for package management and the command-line interface. Linux makes it easy and straightforward to run commands, whereas Windows can require additional configurations, other workarounds, and intermediary steps.

How to install Node Version Manager(NVM) without admin rights

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.

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

Grunt on Windows 8: 'grunt' is not recognized

I'm having a problem running Grunt from the command line on my Windows 8 machine.
My research indicates the most common solution is to install grunt-cli, since Grunt is no longer global. I also need to make sure I actually install the Grunt task runner, since that's not installed with grunt-cli.
Other solutions point to the PATH system environment variable, but that appears to be pointed as I'd expect to:
C:\Users[username]\AppData\Roaming\npm
Having done all that, I'm still getting a "'grunt' is not recognized as an internal or external command, operable program or batch file" error message in the CLI. I've tried the following things, uninstalling everything after every attempt:
Installed grunt-cli globally (npm install -g grunt-cli), then grunt at the directory level I want to use it (npm install grunt)
The same as above, but with the order of installation reversed
The same as both of the above, but using the Admin Command Prompt
Am I missing something obvious?
I've not had any issues with grunt on several different windows 8 machines.
If you open the folder: C:\Users\[username]\AppData\Roaming\npm
Do you have a file named grunt.cmd in this folder?
If not I'd maybe try npm install -g grunt-cli again, maybe from an elevated command prompt.
If this exists and you have C:\Users\[username]\AppData\Roaming\npm in your PATH environment variable then typing grunt from a command prompt should work.
Silly question, have you tried closing the command prompt and opening a new one?
Confirm your PATH is correct (and not messed up). Just type PATH from the command prompt. There's really no other explanation that makes sense given the error you're describing and the steps you've taken.
Normally, using the where grunt command would have found grunt.cmd in your path if npm is installed correctly and it has been properly added to the system path.
Close all Command Prompt instances.
Start a new Command Prompt instance.
Type PATH Enter and verify if C:\Users\Username\AppData\Roaming\npm is part of the path.
If not, you need to log off and on again,or close the Command Prompt and restart the explorer process.
In the Command Prompt, type where grunt Enter.
You're good if it reports:
C:\Users\Username\AppData\Roaming\npm\grunt
C:\Users\Username\AppData\Roaming\npm\grunt.cmd
Otherwise, you have to reinstall the grunt-cli package if it reports:
INFO: Could not find files for the given pattern(s).
Apparently, programs that change the PATH environment variable must broadcast a WM_SETTINGCHANGE message. The Windows' System settings window does it correctly when you change the PATH variable, but the NPM installer doesn't. That's why you have to restart explorer (or log off or restart, which has the same effect).
I know this has been answered but I thought I'd offer my step by step solution for windows 8.
First thing I checked was the PATH in my laptops Environment Variables (Right click my computer > properties > advanced system settings > Environment Variables)
It wasn't listed in there so I added a new variable in User variables (so it was specific only to my user account)
In the new user variable prompt I entered the following;
Variable Name: PATH
Variable Value: %USERPROFILE%\AppData\Roaming\npm
Quit command prompt, repoened, navigated to my projects directory and tried running grunt again and... SUCCESS!
I had the same issue.
I tried different things:
Restart computer
Deleted the grunt folder and ran
npm install -g grunt -cli
Didn't work.
Finally tried:
npm install -g grunt-cli
Worked perfectly.
Tried
where grunt
and I saw 2 locations where it was found.
I was facing the same problem on windows 8
I have added ' %APPDATA%\npm ' to the path variable . It has been working fine.
some times NPM install corrupts the basic windows path. i usually have a copy of my own version of PATH mainted separately. every week or on some installs i manually configure and update the %PATH% variable.
Basically Grunt.cmd is not availbe through %PATH% variable.
I have stucked with problem on Windows 8, that after install grunt-cli I've always got "command not found" while I'm tried to check grunt -v or where grunt. So I've added to enviroment PATH this path C:\Program Files (x86)\Git\local and run grunt.cmd from that folder (you need to look in node_modules folder here). And after reloading my terminal everything started to work.
Same happened to me and here was the solution:
Have you got 2 different versions of Node.JS installed?
Maybe Nodist?
This means you likely got NPM installed twice which will install the commands into 2 different folders:
Once into C:\Users\<user>\AppData\Roaming\npm and once into C:\dev\nodist\bin\bin.
C:\dev\nodist\bin\bin wasn't on my path variable so I added it, and I removed the Node.JS version I didn't want to use.
If you have no grunt.cmd file created by npm, make sure that you do not have a .npmrc in your home directory with: bin-links=false in it.
After getting a tonne of "'grunt' is not recognized as an internal or external command," errors, I solved this on Windows 10 by going to Path and adding C:\Users\Username\AppData\Roaming\npm

Resources