VSCode terminal can't find NodeJs - node.js

my VSCode (Win10) terminal is having issues when running NodeJs commands, such as npm run start (reactJs) or even npm install. I'm getting an error as if NodeJs was not in the $PATH as below. However, when I open the command prompt or powershell (without admin rights) the commands run normally.
Until yesterday it was working fine. Any ideas?
16 verbose Windows_NT 10.0.19041
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start"
18 verbose node v12.18.4
19 verbose npm v6.14.6
20 error code ELIFECYCLE
21 error errno 1
22 error xbet-betfair#0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the xbet-betfair#0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Just to clarify, the files are were they are expected to be and, again, when I run them OUTSIDE VSCode everything works fine. The above is an example, but happens when a npm install requires to run a script to do an install too. For some reason, VSCode terminal can't find node.

Related

Error running Electron

I succesfully had the electron GUI running for testing my app, including the electron hello world application that they have here: http://electron.atom.io/docs/tutorial/quick-start/
Now however whenever I type the command: npm start in the command line I get this error (even when just trying to set up the hello world example again):
12 error Windows_NT 6.1.7601
13 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
14 error node v4.4.4
15 error npm v2.15.1
16 error code ELIFECYCLE
17 error electron-quick-start#1.0.0 start: `electron main.js`
17 error Exit status 3221225781
18 error Failed at the electron-quick-start#1.0.0 start script 'electron main.js'.
18 error This is most likely a problem with the electron-quick-start package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error electron main.js
18 error You can get information on how to open an issue for this project with:
18 error npm bugs electron-quick-start
18 error Or if that isn't available, you can get their info via:
18 error
18 error npm owner ls electron-quick-start
18 error There is likely additional logging output above.
Also one instance of an electron app I set up previously still works when I call npm start.
I would like to be able to setup new apps, partially because my original one doesn't have the correct folder structure.
So using npm list --depth 1 I went to both the folders with both the working electron app, and the not working electron app. Both show electron-prebuilt#1.1.0 as being present. Although using npm list -g shows that electron-prebuilt is not installed globally, perhaps that would be a good idea?
Update Electron to v1.1.1 (npm install electron-prebuilt#latest --save-dev) and that should hopefully solve your issue (which is probably that you're missing the VC++2015 runtime). Installing electron-prebuilt globally isn't going to fix anything.

Why can't execute "npm start" or even other npm commands?

What could the problem be? I get this error whenever i run "npm start" or even basic commands like "npm install." I am trying to figure out why it can't run.
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm- cli.js',
1 verbose cli 'start' ]
2 info using npm#1.4.28
3 info using node#v0.10.32
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart nodetest1#0.0.0
7 info start nodetest1#0.0.0
8 verbose unsafe-perm in lifecycle true
9 info nodetest1#0.0.0 Failed to exec start script
10 error nodetest1#0.0.0 start: `node ./bin/www`
10 error spawn ENOENT
11 error Failed at the nodetest1#0.0.0 start script.
11 error This is most likely a problem with the nodetest1 package,
11 error not with npm itself.
11 error Tell the author that this fails on your system:
11 error node ./bin/www
11 error You can get their info via:
11 error npm owner ls nodetest1
11 error There is likely additional logging output above.
12 error System Windows_NT 6.1.7601
13 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
14 error cwd C:\Users\Kijo\nodetest1
15 error node -v v0.10.32
16 error npm -v 1.4.28
17 error syscall spawn
18 error code ELIFECYCLE
19 error errno ENOENT
20 verbose exit [ 1, true ]
#nox3011
Here is a printout of my directory, if it can help.
You have a ENOENT error which means it was not able to locate some required file or directory. Mostly with ./bin/www
Try running npm start by changing directory to C:\Program Files\node

Grunt stopped working all of a sudden

Tried running Grunt build and Grunt watch on my project yesterday and I ran into the follow error:
Fatal Error: Unable to find local grunt.
I made sure the files weren't deleted. I tried reinstalling Node and Grunt. Files are there and reinstalling didn't work. I've included the debug file for reference. Does anyone know what the issue could be?
0 info it worked if it ends with ok
1 verbose cli [ 'E:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli 'E:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install' ]
2 info using npm#1.3.24
3 info using node#v0.10.25
4 verbose node symlink E:\Program Files\nodejs\\node.exe
5 error install Couldn't read dependencies
6 error package.json ENOENT, open 'D:\sites\alleywire\package.json'
6 error package.json This is most likely not a problem with npm itself.
6 error package.json npm can't find a package.json file in your current directory.
7 error System Windows_NT 6.1.7601
8 error command "E:\\Program Files\\nodejs\\\\node.exe" "E:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
9 error cwd D:\sites\alleywire
10 error node -v v0.10.25
11 error npm -v 1.3.24
12 error path D:\sites\alleywire\package.json
13 error code ENOPACKAGEJSON
14 error errno 34
15 verbose exit [ 34, true ]
You need to install grunt locally with your project (install without -g). This is not the same as grunt-cli which is the grunt command on your command line.
Run npm install inside your project folder if you have a package.json file there.

npm start Error: Cannot find module 'C:\' and Exit status 8

I have a little NPM challenge for you.
Tech. info:
OS: Windows 7
I'm trying to:
cd to the project folder --> run npm start, "start" is configured in the package.json as "node ."
I get the following error:
**** npm start Error: Cannot find module 'C:\'
**** Exit status 8
**** the npm-debug.log look like the below:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm#1.3.24
3 info using node#v0.10.25
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart tile-tease-api#0.1.0
7 info start tile-tease-api#0.1.0
8 verbose unsafe-perm in lifecycle true
9 info tile-tease-api#0.1.0 Failed to exec start script
10 error tile-tease-api#0.1.0 start: `node .`
10 error Exit status 8
11 error Failed at the tile-tease-api#0.1.0 start script.
11 error This is most likely a problem with the tile-tease-api package,
11 error not with npm itself.
11 error Tell the author that this fails on your system:
11 error node .
11 error You can get their info via:
11 error npm owner ls tile-tease-api
11 error There is likely additional logging output above.
12 error System Windows_NT 6.1.7601
13 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
14 error cwd "FOLDER OF PROJECT - EDITED"
15 error node -v v0.10.25
16 error npm -v 1.3.24
17 error code ELIFECYCLE
18 verbose exit [ 1, true ]
During my troubleshooting I have found:
It seems to have something to do with the invoking path. As I have no problems if I do
** instead of "node ." in the start definition in the package.json file I define the actual path
** or if i execute "node ." in a cmd directly instead of doing it through the "npm start" command.
The issue is that I'm sharing the project between other developers and they are developing on Mac's. On their setup it works with the start "node ."....and it would be cumbersome to have different package.json file and would beat the purpose of using Git.....
Have anyone bumped into this problem before and have any ideas for what I can do to overcome this.
I think it's a bug in node.js core, and it might have something to do with the fact that require() doesn't accept "." as a local path.
Try to write node ./ instead.

npm install doesn't work in Windows PowerShell

So my problem is this. I have a project with a package.json. When I in the command prompt (cmd.exe) run "npm install" everything installs as expected. However when I do the exact same thing in PowerShell (powershell.exe) I get an error: "npm ERR! Error: ENOENT, open 'c:\package.json'" even though I ran "npm install" in the path of the project. It always searches for package.json in c: for some reason I can't understand.
Below is the npm-debug.log (which also is written i c: even though my path is c:\code\myProject):
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install' ]
2 info using npm#1.3.11
3 info using node#v0.10.21
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 error install Couldn't read dependencies
6 error Error: ENOENT, open 'c:\package.json'
7 error If you need help, you may report this log at:
7 error <http://github.com/isaacs/npm/issues>
7 error or email it to:
7 error <npm-#googlegroups.com>
8 error System Windows_NT 6.2.9200
9 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
10 error cwd c:\
11 error node -v v0.10.21
12 error npm -v 1.3.11
13 error path c:\package.json
14 error code ENOENT
15 error errno 34
16 verbose exit [ 34, true ]
I can't find a solution to this problem anywhere. The PATH variable is setup correctly since both node and npm itself works.
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

Resources