0

I'm working on some projects to learn how to use angular on my mac (mid 2012 pro, ios mojave 10.14.6) with vs code 2. I've taken some classes before, but my coding experience overall is still pretty limited, especially with the command line and software setup. After downloading node.js, I've had ongoing issues with my terminal, not recognizing 'ng' commands. I've used the top answer from this post and gotten temporary success:

ng: command not found

'ng' commands will work for a little bit, but eventually, I'll have to repeat the steps. For some reason, the changes don't seem to persist. I think the issue may be with my shellpath setup. When downloading node.js, the installer noted to make sure my shell path as '/usr/local/bin'. When I enter 'echo $PATH,' this is the response I get.

/usr/local/bin:/Users/dominickdufner/miniconda3/bin:/Users/dominickdufner/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/bin:

I see references to miniconda4/anaconda3/python, which was a setup from a python class I took over a year ago. I do vaguely remember that setting this up was a massive pain in the @** and took a couple of teaching assistants to figure it out and get set up. I've looked around at how to change my shellpath, but can't get an answer that seems to work.

Thanks in advance.

georgeawg
  • 48,608
  • 13
  • 72
  • 95

3 Answers3

2

please try the code given below, i think this issue comes when npm doesn't know about ng.

so try running this to npm

npm link @angular/cli
  • Is there a specific location i need to do this? i tried from a freshly started terminal and it did not work. see below for what i got after confirming node was installed. Dominicks-MBP:~ dominickdufner$ node -v v12.13.1 Dominicks-MBP:~ dominickdufner$ npm link @angular/cli /Users/dominickdufner/node_modules/@angular/cli -> /Users/dominickdufner/.npm-packages/lib/node_modules/@angular/cli Dominicks-MBP:~ dominickdufner$ ng new test-file -bash: ng: command not found – D_Dufner Dec 04 '19 at 02:23
  • go to node.js command prompt, and then traverse to project path where package.json locate. example cd /d path of your project folder where package.json is located. then run npm link @angular/cli – Ashutosh Kushawaha Dec 04 '19 at 02:26
  • unfortunately i don't know exactly what you mean by 'go to node.js command prompt'. please clarify – D_Dufner Dec 04 '19 at 05:12
0

please find the below solution

1) rm -rf /usr/local/lib/node_modules

2)brew uninstall node

3)echo prefix=~/.npm-packages >> ~/.npmrc

4)brew install node

5) npm install -g @angular/cli

Finally and most importantly

6) export PATH="$HOME/.npm-packages/bin:$PATH"

Also if any editor still shown err than write

umang naik
  • 141
  • 1
  • 10
  • tried this and got a 'brew command not recognized' after the second step. – D_Dufner Dec 04 '19 at 02:25
  • Run below commands: npm uninstall -g angular-cli npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli@latest alias ng="C:/Users/itaas/.npm-global/ng" ( Location of ng file in npm folder) And finally run : ng -v – umang naik Dec 04 '19 at 05:26
  • try to uniinstall first using npm or with sudo user then cache cleanup is also necessary and then again try to install fresh angular cli – umang naik Dec 04 '19 at 05:27
0

Found a solution that has been working and forgot to post before now.

I ended up installing homebrew package manager and then reinstalling angular. it looks like homebrew is only for mac or linux os so i don't know the best option for package managers for windows.

https://brew.sh/