VSCode and starting a project with launch.json - node.js

I installed VScode, but when I try to debug it has giving me an error msg.
Can not find runtime 'node' on PATH. Is 'node' installed?
I don't know what to do. I installed node js and what needed in it's instruction

If you have installed nodejs then you can build the project. You are trying to debug so i think you have done installlation step right. If you try to run a starter project then its version maybe higher then your node. In this state you should install last version of the node.
I think your problem is that your path is wrong.
The file path that project's itself and the compiler looking for, should not contain any invalid character, like empty ş, i, ü, etc..
Your project has to read and write permission to that directories.
You should try aboves, your error may be change or if your launch.json is right then it will work out

try to check
run cmd => 'node --version'
if it is installed well, you can check the version.
if you cant check the version, add a environment variable
bascially node.js path is ''C:\Program Files\nodejs\'
Add the path into 'Path' of 'System variable'

Related

Angular: ng new error when I create an angular project

I have this error using ng new project_name:
An invalid configuration file was found ['angular.json']. Please delete the file before running the command.
I am getting this error I don't know how to get the solution.
I uninstalled #angular/cli and installed again
npm clean cache doesnt work too (I dont know if it is problem of my npm version
npm version is 6.4.1
node version is 8.11.1
what do i need to solve the problem?
If you are using the terminal of IntelliJ IDEA while there is a angular project already imported in the IDEA, it is the problem of the IDEA.So, open the command promt of your windows and create the project.
I did this and I was able to create the project.
The problem seems to be the _ in project_name resulting in the following error:
Schematic input does not validate against the Schema: {"name":"project_name","version":"6.0.1","newProjectRoot":"projects","skipInstall":false,"linkCli":false,"skipGit":false,"commit":null}
Errors:
Data path ".name" should match format "html-selector".
Replace _ e.g. with -.
Further readings:
Error when creating new project with Angular-CLI 6.1.2
Style Guide
Setting the working directory in IntelliJ's Karma task, to the Angular project's main directory, also fixes the problem.
I deleted the file in c:\users\XXX\.angular.json and it was running ok.
Run following if file is hidden. Open Terminal, run mv /Users/shivammishra/.angular.json /Users/shivammishra/angular.json.txt.
mv command will move the file to new location (angular.json.txt) and you can then delete.
Angular.js & Wrong Directions.
First of all, open a file called angular.js in the root folder.
And check if you add some wrong Directory. like the style or something like that. as example.
Suppose you add the bootstrap dependency and you want to add it to your project you will go to the angular.js and add it in the style configuration. so you will add it as the below:
"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
Check if you add double dot .. not one dot in the path like the below:
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
Or you maybe add it in the following format:
"/node_modules/bootstrap/dist/css/bootstrap.min.css",
or
"node_modules/bootstrap/dist/css/bootstrap.min.css",
The correct format is :
"./node_modules/bootstrap/dist/css/bootstrap.min.css",

how to set default node read location for extension in vs-code?

Pre-problem
I install npm and node using nvm, so that make my npm and node location in directory
npm /home/putrapc/.nvm/versions/node/v8.9.4/bin/npm
node /home/putrapc/.nvm/versions/node/v8.9.4/bin/node
all i install in stable version
The problem
I start using vs-code and there is always error notification that annoy me, like this
I realize that problem because the extension in vs-code like jsHint, flow, Javascript standard style, etc doesn't read any of my npm package properly. Yes it cause the directory isn't correct, how to change default read directory in vs-code ?
My eslint directory
/home/putrapc/.nvm/versions/node/v8.9.4/bin/eslint -> /home/putrapc/.nvm/versions/node/v8.9.4/lib/node_modules/eslint/bin/eslint.js
i had eslint installed as package, but the vs-code still didn't read it. How to correct this?
I was encountering similar issues with VS Code extensions encountering issues when trying to run Node with error messages such as
/usr/bin/env: ‘node’: No such file or directory
The simplest solution I found to this is to use a terminal to start Visual Studio in the folder that you're trying to open from
This can be done by navigating to the folder you're trying to open in Code, opening a terminal there, and typing in
$ code .
The above behaviour seems to happen because NVM sets its own variables for the node location and that is what is used by default in your terminal session. You can check these using
env | grep NVM
This returned the following for me
NVM_DIR=/home/saikat/.nvm
NVM_CD_FLAGS=
NVM_BIN=/home/saikat/.nvm/versions/node/v12.0.0/bin
Also, trying to get the current Node location using which returns the following
$ which node
/home/saikat/.nvm/versions/node/v12.0.0/bin/node
When starting Visual Studio Code from anywhere apart from the terminal, the above NVM variables don't get set and hence the extensions try to find node at the default location /usr/bin/env and are unable to find it there and hence fail

How to configure nodejs on vscode extension on Mac

i use vscode on Mac for nodejs applications.
I installed the **Mocha Side Bar** module, for help me test my unit tests.
The problem is that vscode doesnt see the 'Nodejs' installation, and each time i try to execute the 'mocha test run', i am getting these errors:
The root of my nodejs installation is on that path: /Users/theodoros.itzaris/.nvm/versions/node/v6.11.5/bin/node
It seems a simple configuration issue, but i m new to both mac & vscode.
And i did not manage to find any tutorial on that.
You can specify an absolute path to your nodejs installation by setting the program attribute in your launch.json:
"program": "/Users/theodoros.itzaris/.nvm/versions/node/v6.11.5/bin/node"
All available launch configuration attributes can be found in this docs.
Update
Here is explained how the extension works and furthermore stated
It will search for the installed Node.js as indicated by environmental variable PATH
Therefore ensure that you have added node.js to your system's PATH variable.

node 6.11.3 NODE_EXE not found in IntelliJ

I've updated my project to use node 6.11.3. When I now try to start a npm-script by using the Run-configurations provided from IntelliJ, I always receive the following error:
Error: Failed to replace env in config: ${NODE_EXE}
Important: This error appears only if I start npm from within my project. If I use the windows cmd, the error doesn't appear.
What could possibly have changed between node 6.11.2 and 6.11.3? Because with the prior version, everything worked fine.
A workaround for me is to add the NODE_EXE variable to my run configuration, but In my opinion, that shouldn't be needed, because it worked in 6.11.2 too.
Looks as if you have ${NODE_EXE} variable set in one of your npmrc files (see https://docs.npmjs.com/files/npmrc#files), and it can't be properly expanded for some reason when you run your script in the IDE.
is the issue specific to certain project?
how many npm versions do you have installed? Please check that npm chosen in Node.js Interpreters dialog is the same as you use in cmd shell?
please create an env.js file with console.log(process.env) and try running it via npm ("env" : "node env.js") in both cmd console and WebStorm - what is the result?

Error code: 800A1391 Source: Microsoft JScript runtime error Running Grunt - Module is undefined

New Grunt user here who is using a lot of new tools (npm nodejs) today.
I've got Grunt "installed" and have been able to create a grunt.js file using the init task as described here: http://net.tutsplus.com/tutorials/javascript-ajax/meeting-grunt-the-build-tool-for-javascript/ and here: https://github.com/cowboy/grunt/blob/master/docs/getting_started.md. But whenever I run the "grunt" command I get an error:
Windows Script Host
Script: c:\users\[]\Documents\code\grunt\grunt.js
Line: 2
Char: 1
Error: 'module' is undefined
Code: 800A1391
Source: Microsoft JScript runtime error
As explained in the FAQ, you need to type grunt.cmd instead on Windows because the OS tries to launch grunt.js
Or you can install grunt-cli globally instead. This package will run any version of Grunt if it's been installed locally to your project.
SOLVED !!
So, this problem occur because windows by default associative < *.js > files
with >>
"Microsoft Windows Based Script Host".
grunt need to open by default with (grunt.cmd).
it easy to slove, by change default app (open with..)
Guide :
Go to any javascript file with "js" extension. (any file)
Right-Click(mouse) > Properties > "Opens with:" Change...(button)
Choose Notepad ( or any javascript IDE ).
PROBLEM SOLVED ! :)
good luck
If you're getting a "Microsoft JScript runtime error" that means that node.js isn't even getting invoked; instead Windows Script Host is trying to run your code. That's probably a problem with filetype associations; IIRC Windows defaults to trying to execute a ".js" file with WSH. You may wind up having to create a shortcut to your script, specifying a command line (probably something like "node %1") and a starting directory in order to make sure that it's executed properly.
It would help if you could tell us exactly how you're trying to invoke your code.
it seems that in the latest versions of the grunt modules, you would have to do the following to have it work under windows:
remove any globally installed grunt
npm uninstall -g grunt
install grunt-cli globally
npm install -g grunt-cli
install grunt locally into your project
npm install grunt
installing grunt (v0.4.x) globally does not seem to create the necessary grunt.cmd anymore. it seems that the recommendation is now to have grunt installed locally to be able to use version-specific Gruntfiles
As Florian F suggested, running grunt.cmd works. This is because of the process Windows is looking for your grunt command.
When typing grunt -h Windows will proceed to look for the following files:
./grunt.cmd
./grunt.* (grunt.js is found in this case which is why you see "module is undefined")
%APPDATA%/npm/grunt.cmd
An alternative to using "grunt.cmd" is to use grunter which simply renames the command to grunter... then you no longer have this problem.
To answer this, first we need to understand that the error is caused because it is being executed by Windows Script Host.
Now, run the code from your cmd promt with the following syntax:
>node <application_name>.js
this will allow the Node.js application to open through V8 JavaScript engine(Google's).
P.S: Please reply back if this has helped in resolving your issue else post the problem you are facing after trying this.
I had a similar issue, the problem is file association, I would recommend:
right click on a .js file and choose open with.
then you choose nodejs/node.exe (somewhere in "program files" folder
then make tick box where it says "always open .js files " (paraphrasing)
That should do the trick.
I went through the same issue when running an old Node project.
The issue was with the name of the js file, it was node.js. So the while running the command node node.js, it was opening up a windows dialogue box.
I just changed the name of the file to app.js and the error flew away.
So, in my case i had tryed all the mentioned above with no result.
But i have fund that im dont type: node in the full sentence as the following snipet
node script.js.And remember never understimate your own miscoding.
Solution:
Go to any javascript file with "js" extension. (any file)
Right-Click(mouse) > Properties > "Opens with:" Change...(button)
Choose Notepad ( or any Javascript IDE like VS Code ).

Resources