Angular: ng is not recognized as a command - javascript

C:\Users\Vivek Ghanchi>ng
'ng' is not recognized as an internal or external command,
operable program or batch file.
I have installed angular CLI but it is showing me the ng is not recognized is there any solution

Use;
Environment Tables -> System variables -> Path:
C:\Users\*'Your User'*\AppData\Roaming\npm
not
C:\Users\Administrator\AppData\Roaming\npm**\node_modules\angular-cli\bin**
Be aware that the path should point to YOUR USER work directory if You are not working on Administrator account.

You should install angular cli by enter the following command:
npm install -g #angular/cli

I solved it few days ago, after having the same problem with other global modules, by adding to:
Environment Tables -> System variables -> Path:
C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin;C:\Program Files\MongoDB\Server\3.2\bin
Note that it must not have any spaces after ;
That turned out to be my problem.

Use this link to know about angular CLI. After installing Angular CLI you can able to see workable ng command.

I was facing the same issue, I uninstalled node js and then reinstalled it. Now if you run node --version, it will show current version of node, Its 14.16.1 in my case. Now run command npm install #angular/cli. It will install angular CLI. One can also run npm --version before angular cli installation for being sure that npm is working. Might be helpful for someone.

try ng --help to see if your command parameter is in the list, and word is correct. For example, ng -v is not support in new version, use ng v instead.

Related

Angular 9 ng new stuck at installing packages

I have just installed the node version 12.16.1 the LTS and
angular cli version 9.0.3.
At the time of creating new project with cli all files in root folder are generating but it is stuck at the part of installing node packages.
Is anybody facing the same issue? Please help how can we resolve it.
Run command npm i -g npm#latest
Run command npm i -g #angular/cli#latest
It worked for me.
Every time you create a new project the angular suppose to download huge chunks of file of size around 500mb, all the time that is been taken is actually the time taken to download those file in the background. A good internet connection is the solution.
I changed directory and then run these command and it worked for me
sudo npm cache clean --force
sudo npm cache verify
sudo npm i npm#latest -g
ng new my-project
Another Solution:
Cancel the installing packages with ctrl+c
and then go to the files of project and run command npm install
This also worked for me
I faced the same issue quite a few times.
Try using: ng new project_name --skip-install
And then, go to the file and do npm install
I had exactly the same problem.
I tried everything. Reinstallation of node several times. Latest version didn't change anything. Stuck at Installing packages (npm)...
I was running node.js within a virtual machine. Only 1 gig of memory was allocated to the VM. Allocating more memory (from 1 gig to 4 gig) solved the problem. if there is not enough memory, node.js does not complain but seems stuck.
I can reproduce the problem. Now with 4 gig instead of 1 gig, ng new app took only 30 seconds.
You can set up one workspace (one folder) for all your applications, by running
ng new your_workspace --create-application false
and then create your new apps inside this workspace
cd your_workspace
ng generate application testApp
Maybe it helps to your needs

Cannot find module '../build/Release/opencv4nodejs

I am new to OpenCV and node js, trying to learn OpenCV in node js.
I came across opencv4nodejs which I found best for learning.
I have followed all steps to install OpenCV and setting environment variables for OpenCV and done npm install opencv4nodejs also. able to run Quick start code given but when I try to run example machineLearningOCR.js from examples folder I get error Error: Cannot find module '../build/Release/opencv4nodejs'
I run command node machineLearningOCR.js from cmd but getting error mentioned above on line const cv = require('../');
How to run examples given in opencv4nodejs?
If you cloned the repository and want to use the examples directly from the examples folder then you have to npm install in the root directory first to build the module.
Optionally you can npm install opencv4nodejs in any project directory, copy the examples into that directory and replace const cv = require('../'); with const cv = require('opencv4nodejs');.
You can also directly submit an issue here: https://github.com/justadudewhohacks/opencv4nodejs/issues
I had the same problem and I did solve the issue with the following steps.
First all of. I checked the npm version, for this case I recommend you updated or pass your software resources at the next version.
NodeJs 14.16.0
NodeJs version: 14.16.0. You can verify the version with this command if you had another NodeJs version installed
node --version
Npm version: 6.4.11 You need verify if you had this version installed only you will able to validate this if you have NodeJs but if you didn't have node you can install the version I recommend you
npm --version
After you set the NodeJs and npm versions you need to verify the following things
Have visual studio 2015 or latest with the development for desktop component
Have cmake program installed
Have git bash
Have Java or the language you will to work
Have the environment variables for the above programs I mentioned
Then you can try again to install open Cv
You need to reopen another or new terminal and then you will execute this command
npm install --save openc4nodejs
And then
npm install -g openc4nodejs
After than or before don't forget to install appium I recommend you 1.19.1 version
You can verify if you have appium with opencv with open Cv doctor you can run appium-doctor and check if the Open cv component are present.
For to install appium doctor you can run this command, npm install -g appium-doctor
I hope this answers will be helpful for you
Autor: Eder Carbonero

Yarn global command not working

I'm working with Yarn v0.16.1. If I understand correctly (according to the documentation), yarn global add <package> should be the equivalent of npm install -g <package>. However, when I run the example in the docs (with create-react-app), the command runs successfully but create-react-app is then not available from the command line. Here's the output:
$ yarn global add create-react-app
$ yarn global v0.16.1
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 📃 Building fresh packages...
success Installed create-react-app#0.6.0 with binaries:
- create-react-app
✨ Done in 3.22s.
$ create-react-app --help
-bash: create-react-app: command not found
Doing a global install with npm has the expected result, and everything works. What am I missing with yarn?
You should add export PATH="$PATH:$(yarn global bin)" to your ~/.bash_profile or whatever you use. It would solve the issue.
Depending on how you installed it, Yarn's global folder varies for some reason. You can follow this issue here.
Update Dec 2018
Just updating the path didn't work for me. I had to also set the yarn prefix.
Ubuntu 18.04.1 LTS (bionic)
yarn 1.12.3
npm v3.5.2
node v8.10.0
zsh 5.4.2
Steps
Confirm your global bin path
yarn global bin
I got: /home/username/.yarn/bin
set yarn prefix:
make sure your yarn prefix is the parent directory of your bin directory. You can confirm by running
yarn config get prefix
when I ran this, my prefix was empty, so I set it:
yarn config set prefix ~/.yarn
add the following to ~/.bash_profile or ~/.bashrc
export PATH="$PATH:`yarn global bin`"
for zsh users, be sure to add this line to ~/.zshrc
restart your shell or start a new one
bash -l or zsh
In my case yarn global bin wasn't working.
Try a brew reinstall yarn if that's how you installed yarn
👍🏻
Ran into this issue but on a Windows system. All I had to do was add the yarn global bin to the PATH variable.
setx path "%path%;c:\users\YOURUSERNAME\appdata\local\yarn\bin"
Remember to change YOURUSERNAME to your account username.
You can check where your global bin is by running
yarn global bin
And please don't forget to restart the CMD window that you're working on.
Happy coding!
! WARNING !
When executing the command that %path%; in front of your yarn directory is very important. If you don't type it you will definitely replace all your system environment variables.
Option 2
Safer option would be would be to just go to System Properties > Advanced > Environment Variables > select PATH the click Edit > then append and not replace with ;c:\users\YOURUSERNAME\appdata\local\yarn\bin
For macOS, you just need one step,
export PATH=~/.yarn/bin:$PATH
To reinstall run below.
brew install -g yarn
// Note:(updating homebrew) for Mac users.
brew reinstall yarn
// (if yarn is still not found)
Here's the process I used on Mac OSX El Capitan.
Try to install yarn (I used the Curl command) if you have it already. This will bring up if its already installed and will give you the current directory where it exists.
Like this:
curl -o- -L https://yarnpkg.com/install.sh | bash
It will display something like this:
Installing Yarn!
> /Users/{Your Username}/.yarn already exists, possibly from a past Yarn install.
> Remove it (rm -rf /Users/{Your Username}/.yarn) and run this script again.
Do not remove it. Move on to step 2.
Copy the directory listed above. Open your profile. I'm using zsh. So mine was ~/.zshrc. You can find yours and more info here.
Copy the following (replacing your directory and username details as necessary, the one you got from the installation error message).
alias yarn="/Users/{Your Username}/.yarn/bin/yarn"
Try to run yarn version to check if its working. If it is, you should see a version number displayed in your terminal.
That's it, and what worked for me.
AndrewD gave a great answer, but for those on Windows it's a bit different, especially step 3.
Please do not use the command setx as #Thapedict said.
It will remove all your previous paths you had and replace it with only the given directory.
If you want to use setx, I think there might be a flag to make it append the existing path variables, but I don't know which one. Using only setx will not append to it.
I would just do System Properties > Advanced > Environment Variables > Edit Path > New > c:\users\YOURUSERNAME\appdata\local\yarn\bin
to make sure you don't remove your previous variables.
export PATH="$PATH:$(yarn global bin)"
On Ubuntu, I fixed by installing the package like this:
sudo yarn global add <package> --prefix /usr/local
When switching from bash to zsh, I got the same error, it worked for me:
in your .zshrc
# NVM Stuff
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
# YVM Stuff
export YVM_DIR="$HOME/.yvm"
. "$(brew --prefix yvm)/yvm.sh"
As I understand it, my mistake arose due to the lack of access to version managers
I faced a similar issue on Windows after installing Yarn then Vue Cli.
Packages were installed but not accessible.
The problem was that the directory where yarn packages are installed is not in PATH.
The default installation directory for Yarn packages in my case was
C:\Users\USERNAME\AppData\Local\Yarn
So make sure to add this directory to path.
Putting this answer so that hopefully it can come in google and help others.
expo command not found after using
yarn global add expo-cli don't work in ubuntu 20.04
It's no longer necessary to modify your path for yarn
Newer versions of yarn include yarn create and yarn exec
In the case of create-react-app you can run yarn create react-app see this blog post https://classic.yarnpkg.com/blog/2017/05/12/introducing-yarn/
To run a non-creating package like serve, you can still run it without modifying your path! After installing it with yarn global add serve try this: yarn exec serve

Error: Module did not self-register.

Server: Ubuntu server 14.04
Node: v4.2.6 LTS
npm: 1.3.10
I pullled my colleage's work from git remote. He made the node_modules as .gitignore. So I have to npm install the modules.
But after a successful install of npm. when I try to start the project using mocha. It remind me of a module didn't self-register
The error comes from the module of Bcrypt.
at bindings (/base_dir/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44)
I don't want to downgrade my node to 0.10, because, I can't use JS promise in that version. Somehow, JS promise is a must in my work
This problem happens mostly because you copied/cloned the repository from somewhere else, but some modules for nodeJS should be installed/registered locally on your machine, during which the happens the build process(maybe some native language like C).
and be noted that the node_modules folder should not be staged for versioning. and should be ignored by versioning tool. and the one who is trying to clone this package should build / install firstly.
I find the answer to this problem.
But plz don't devoted this just because you want.
I upgrade the NPM using
npm install npm -g.
after that, delete the node_modules folder,
then,
npm install
Everything will be good.
I had this issue while setting up my Cypress project.
After trying to delete and then reinstalling all the node-modules and upgrading everything I found out the issue was caused because Cypress uses node from its bundle version by default (which was version 8.0 in my case) , whilst the package I wanted to use required the node version to be 10 or higher.
I did have node 12.0 installed on my machine but since cypress was not using that I had to add the line shown below in the settings file (cypress.json) to set the value for 'nodeVersion' to 'system', this way you are telling cypress explicitly to use the node version installed on your machine.
Add this line to your settings file:
**"nodeVersion": "system"**

Node.js says it can't load sqlite3 module, but does anyway

I'm working with the new Node.js Tools for Visual Studio and included the sqlite3 npm module. When I call require('sqlite3') it throws the error:
Error: Cannot find module './binding\Debug\node-v11-win32-ia32\node_sqlite3.node'
Odd thing is, when I ignore the error and continue running the code, everything works fine...until the function I'm in returns; then the server crashes.
Has anyone else had this issue? I have a suspicion that it has something to do with the ./binding part, but wouldn't know where to begin in terms of finding out why.
use this:-
npm install sqlite3 --build-from-source
This is what worked for me: https://www.npmjs.com/package/sqlite3
npm install https://github.com/mapbox/node-sqlite3/tarball/master
From: https://github.com/mapbox/node-sqlite3/wiki/Building-On-Windows
Install required software:
Python 2.x: https://www.python.org/downloads/release/python-2711/
Win SDK: http://www.microsoft.com/en-us/download/details.aspx?displayLang=en&id=8279
Microsoft Visual Studio 2010+: https://www.microsoft.com/es-es/download/details.aspx?id=48217
Build:
npm install sqlite
npm install
node-gyp configure build
I got the kind of problem, my node version is v10.16.3
This globally installed sqlite3 gives error in loading by require('sqlite3')
It been solved by install a sqlite3 local to project.
$ npm install sqlite3
Note without -g option, it works for me.
It seems this is a problem with the sqlite3 npm package itself. There exists a lib\binding\Release\ folder, but not a lib\binding\Debug\ folder. I just created a copy of the Release folder, named it Debug, and all is well.
In case this above has not worked for anyone, here is what worked for me:
sudo apt install node-sqlite3
(I am using Ubuntu with Vscode as editor). It seems installing this node-sqlite3 module was the one that was recognized.
To skip searching for pre-compiled binaries, and force a build from source, use
npm install --build-from-source

Categories

Resources