'ng' is not recognized - Running an Angular app via electron - node.js

I know this question has been asked already, but the reply was not helpful to me.
I try to run an Angular app in electron by typing in Visual Studio code integrated terminal the following command:
npm start
The error I get is:
'ng' is not recognized as an internal or external command,
operable program or batch file.
The log file looks as following:
Now:
I have node installed:
Running command node -v gives me - v8.9.4
I have angular Cli inatalled.
Running the command npm list #angular/cli
gives me: `-- #angular/cli#6.0.3
I went to the folder of Environment Variable
The PATH variable looks as following:
C:\users\dim\AppData\Roaming\npm\node_modules\#angular\cli\bin;C:\Program Files (x86)\Microsoft VS Code\bin
What else can I do in order to solve the issue?

Your PATH variable should not contain C:\users\dim\AppData\Roaming\npm\node_modules\#angular\cli\bin but C:\users\dim\AppData\Roaming\npm.
Here are the .cmd files that are created when you install libraries globally :
npm i -g #angular/cli#latest

Related

nmp install -g under Windows 10, not recognized as a command

While logged in to Windows 10 as a User, and opened the command prompt as an Adminstrator, cd to my nodeJs project directory and did npm install browser-refresh -g in order to install the browser-refresh package from the npm which went ok but with some "npm WARN deprecated" messages. and the confirmatioin
browser-refresh#1.7.3
then I modified my code according to the package instructions and did browser-refresh index.js which suppose to replaces node index.js but I get the error
'browser-refresh' is not recognized as an internal or external command, operable program or batch file.
So I installed it locally with out the -g tag for no avail. I able to run it using the command C:\Users\adminName\AppData\Roaming\npm\browser-refresh index.js
I added the path above to the list of Paths under "System variables > Path" for no avail. I may un install the local package since that did not work. Someone please suggests a working solution.
Even though I get it running with the long command, the pacakge did not refresh the web page after changed the index.html file and saved it but this may be a different question.
Thank you
The path to the NPM bin folder may not be defined in your PATH environment variable. You can test this by installing another package that should be executable from the command line and checking to see if executing it results in the same error.
If it does, you can "%AppData%\npm" to your PATH. Here are instructions on how to do so.
Hope this helped!

AngularJS project ng command not recognized but npm run ng works

Important point: this is AngularJS project.
I cannot install #angular/cli.
I have installed node v8.11.3 (with NPM v6.7.0).
Then installed AnguarJS
npm install angular#1.7.2
At this point, I cannot run
ng serve
Error: 'ng' is not recognized as an internal or external command,
operable program or batch file.
However, I can run:
npm run ng serve
And everything runs as it should.
I can't find where ng is in order to put it in my path, yet npm seems to have no trouble finding it.
Any suggestions? NOTE: I am not allowed to move to Angular 2+.
Thanks in advance.
I am finding this CLI that was being added does not support the version the project was originally written for. When I changed to the latest CLI (and took steps to perform the audits), the project runs correctly. My apologies.

tsc is not recognized as an internal or external command

I am using node version 6.9.2 with npm version 5.4.2 on Windows7. I have installed typescript with the command npm install typescript -g.
However, when I run a demo file using command, tsc, I get an error:
"tsc is not recognized as an internal or external command".
Could anybody help? Other node modules get installed correctly and working fine. Not sure why typescript isn't working.
The problem is likely that tsc is not in the system path.
First, check if tsc is installed correctly. Open cmd.exe and type the following.
%AppData%\npm\node_modules\typescript\bin\tsc --version
If there is a version log, then tsc is installed successfully.
The next thing is to add it in PATH. Write in cmd.exe
setx path "%path%;%AppData%\npm\node_modules\.bin\"
This should solve the issue.
However, if the first command did not log the version,
Check the install location using
npm list -g
If typescript appears in the output, copy the location to the PATH as
setx path "%path%;<--the tsc.exe path-->"
Hope this helps.
Since you installed it globally and you had no error, I can assume that the installation succeeded.
To be sure, you can run this command npm config get prefix. It will output the path of the folder containing all packages installed globally by npm. I you go to the folder specified by the path, there is a nodes_modules subfolder. It should contain a typescript folder if the installation succeeded. Then copy the path of the bin of the typescript folder in your environment variable. You should label the path tsc.
Then you can use tsc in command line.
I found this solution in this website and it worked for me.
-> If you are on windows and getting this error "'tsc' is not recognized as an internal or external command."
Solution
-> add the following path "C:\Users\user\AppData\Roaming\npm" to the PATH variable replace user with your windows user.
-> Restart the System.
Reference:- https://www.typescripttutorial.net/typescript-tutorial/setup-typescript/
Install node version 6.11 and things work without any changes.

Using GRUNT from NodeJS error message "'grunt' is not recognized as an internal or external command, operable program or batch file"

The webproject that I am working on uses SASS which is compiled into Grunt tasks, and grunt is supposed to run in NodeJS.
I have been given these instructions but it's not working:
I installed NodeJS (default folder/settings)
I then went in my project folder in CMD C:\Users\Ben\Desktop\officeincambridge>
Then ran the command npm install -g grunt-cli
and npm install grunt
If I type NPM version (in dir above) I get npm --version: 1.4.14 , node --version: v0.10.29
However, when if I try and compile the files using grunt sass i get this error message 'grunt' is not recognized as an internal or external command, operable program or batch file.
Can anyone assist me on how to use it (I have never used grunt before). HERE are the instructions which I am using.
Thank you
Try to install
npm install -g grunt-cli
This seems to be a duplicate of this question: Grunt on Windows 8: 'grunt' is not recognized
In his case, it was a PATH issue. Check that your PATH is correct. It must contains the path where npm is installed: C:\Users\Ben\AppData\Roaming\npm
I also had the same issue :
To Solve this
I have added "grunt path" in SYSTEM environment Variable .
C:\Users\\AppData\Roaming\npm\grunt
To find your grunt path Use Command(in cmd) : where grunt
Once Added Path to SYSTEM Environment Variable Restart Jenkins and build job again

Running karma after installation results in 'karma' is not recognized as an internal or external command

I'm trying to run karma as part as an angular-seed project, after installing karma using
npm install -g karma
I get:
'karma' is not recognized as an internal or external command, operable program or batch file.
when i'm trying to run test.bat from angular-client\scripts, the content of this file is:
set BASE_DIR=%~dp0
karma start "%BASE_DIR%..\config\karma.conf.js" %*
I also tried to navigate to "\AppData\Roaming\npm\node_modules\karma\bin" and saw karma file, when I'm trying to run it I get again:
'karma' is not recognized as an internal or external command, operable program or batch file.
Any suggestions?
If not please suggest how to use jasmine without karma.
Thanks.
The command line interface is in a separate package.
To install this use:
npm install -g karma-cli
karma-cli
It is recommended to install karma with its Command-Line-Interface (karma-cli) which will take care of fetching the appropriate karma. You can also install a different local version specific to each project you're working on and karma-cli will pick the appropriate one.
From the karma installation page:
Typing ./node_modules/karma/bin/karma start sucks so you might find it useful to install karma-cli globally:
npm install -g karma-cli
Now, check that karma was installed by typing:
which karma //echo something like: /usr/local/bin/karma
and check that karma server is working (ctr+c to quit):
karma start
You can also check that karma was installed by going to this directory:
cd /usr/local/lib/node_modules/karma
Good luck!
On windows when you install a npm (non-globally - so without the -g flag), the executable commands are linked in the node_modules\.bin folder.
For example:
powershell> .\node_modules\.bin\karma start
powershell> .\node_modules\.bin\karma run
I had the same issue and fixed it by correcting my PATH environment variable.
STEP 1: go to the following path and ensure karma.cmd is present at the location given below
[Nodejs folder path]\node_modules\.bin <=> C:\Program Files\nodejs\node_modules\.bin
STEP 2: If present go to STEP 3, If not present run the following command npm install -g karma
STEP 3: Open environment variables and edit PATH
STEP 4: Add the following at the end :
[Nodejs folder path]\node_modules\.bin; <=> "C:\Program Files\nodejs\node_modules\.bin"
Log out your session and it will work for sure.
Based upon your directory using \AppData\Roaming, you're on Windows and this error is usually because the path to the npm globals isn't in the Windows PATH or NODE_PATH environment variables.
Use SET to check the values you are using for the paths and if your npm directory isn't listed, that will be the issue.
If you don't want npm to save to this directory, check the npm configuration options and the npm folders docs to see what you can change in this regard...
'karma' is not recognized as an internal or external command, operable
program or batch file.
If the above mentioned solution does not work, than
The cause of issue is previous version of nodejs. So uninstall the previous version of nodejs and re-install the latest version. It will resolve your issue. As I faced the same and by doing above changes it worked for me.
Thanks.
Official documentation at https://karma-runner.github.io/0.12/intro/installation.html is confusing. It implies that npm install -g karma-cli is to install karma globally but it actually required for to run karma from command line.
I had same: 'karma' is not recognized as an internal or external command, operable program or batch file. problem when i tried to install it directly to my project file. When i used npm install -g karma-cli to global install everything worked just fine.

Resources