program tip

ng : angular-cli를 사용하여 새 프로젝트를 만드는 동안 명령을 찾을 수 없습니다.

radiobox 2020. 10. 31. 09:33
반응형

ng : angular-cli를 사용하여 새 프로젝트를 만드는 동안 명령을 찾을 수 없습니다.


( npm install -g angular-cli)를 사용하여 angular-cli를 전역 적으로 설치 했지만 사용하여 프로젝트를 만들려고 할 때 ng new my-project오류가 발생합니다.

ng : 명령을 찾을 수 없습니다.


문제는 간단하다, npm모르는에 대한ng

실행 만하면 npm link @angular/cli원활하게 작동합니다.


첫째, angular-cli은 더 이상 사용되지 않으며로 대체되었습니다 @angular/cli. 따라서를 사용하여 기존 angular-cli npm uninstall angular-cli를 제거한 다음 @ angular / cli라는 새 이름으로 패키지를 다시 설치하면 충돌이 발생할 수 있습니다. Windows 7에 대한 제 이야기는 다음과 같습니다.

angular-cli를 설치하고을 사용하여 다시 설치 npm install -g @angular/cli했지만 명령 줄 도구에 대한 구성 변경을 수행 한 후 ng 명령을 찾을 수 없음 문제가 발생하기 시작했습니다. 이 문제를 해결하기 위해 몇 시간을 보냈지 만 위의 문제 중 어느 것도 혼자 작동하지 않았습니다. 다음 단계를 사용하여 문제를 해결할 수있었습니다.

Rapid Environment Editor를 설치 하고 node, npm, angular-cli 또는 @ angular / cli에 대한 모든 PATH 항목을 제거합니다. Node.js는 시스템 경로에 있고 npm 및 각도 항목은 사용자 경로에 있습니다.

node.js를 제거하고 현재 버전 (6.11.1)을 다시 설치합니다. Rapid Environment Editor를 다시 실행하고 node.js 및 npm이 시스템 또는 사용자 경로에 있는지 확인합니다. 다음을 사용하여 기존 ng 버전을 제거하십시오.

npm uninstall -g angular-cli

npm uninstall -g @angular/cli

npm cache clean

삭제 C를 : \ 사용자 \ % YOU % \의 AppData \ 로밍 \ NPM \ node_modules \ @angular 폴더에 있습니다.

재부팅하고 마지막으로 다음을 실행하십시오.

npm install -g @angular/cli

그런 다음 숨을 멈추고 달리십시오.

ng -v

운이 좋으면 사랑을 얻을 수 있습니다. ng 명령을 실행할 때마다 숨을 참으십시오. ng가 정상적으로 실행 된 후 'command not found'가 마법처럼 여러 번 나에게 다시 나타 났고 문제가 해결되었다고 생각했기 때문입니다.


npm 디렉토리가 " Path "변수 에 있는지 확인하십시오 .

모듈이 제대로 설치된 경우 전역 노드 모듈 디렉토리에서 시작하면 작동 할 수 있지만 명령 줄 도구는 ng이 디렉토리에 없을 때 명령 을 찾을 위치를 알지 못합니다 .

들어 승리의 시스템 변수 무언가를 같이 추가 :

%USERPROFILE%\AppData\Roaming\npm

유닉스 계열 터미널 (에뮬레이터) 을 사용하는 경우 :

PATH=$PATH:[path_to_your_user_profile]/path-to-npm

가장 쉬운 해결책은 ( 이미 angular를 설치 한 경우 )입니다.

1 존재하는 경우 ng 별칭 제거

unalias ng

2 올바른 별칭 추가

alias ng="/Users/<user_name>/.npm-global/bin/ng"

예를 들어 3 실행 ng 서비스가 작동합니다.


아래 명령을 실행하십시오.

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" (npm 폴더의 ng 파일 위치)

그리고 마지막으로 실행하십시오.

ng -v 

Ng-v


이것이 나를 위해 일한 방법입니다 :).

1 - npm link @angular/cli

다음과 같은 cli 경로를 반환합니다.

/usr/local/Cellar/node/11.3.0_1/lib/node_modules/@angular/cli

이 부분의 경우 /11.3.0_1다음을 입력하여 찾을 수있는 각 노드 버전으로 바꾸십시오.node --version

2- cd ~/

삼 - open .bash_profile

bash 프로필에서 다음 과 같이 cli에 대한 별칭만듭니다.

alias ng="/usr/local/Cellar/node/11.3.0_1/lib/node_modules/@angular/cli/bin/ng"

4- source ~/.bash_profile

별칭.bash_profile추가하면 다음과 같이 표시 됩니다 .

여기에 이미지 설명 입력

이제 ng터미널에 입력 하면 첨부 된 스냅 샷에 표시된 출력이 표시됩니다.

여기에 이미지 설명 입력

이 답변이 도움이되기를 바랍니다.


다음과 같은 별칭을 추가하여 동일한 문제를 해결했습니다.

alias ng="path-to-your-global-node-modules/angular-cli/bin/ng"

Mac의 경우 실행

npm install -g @angular/cli@latest

그런 다음 실행

alias ng="/usr/local/lib/node_modules/node/lib/node_modules/@angular/cli/bin/ng"

작동하는지 확인

ng version

우선 npm 및 노드
가 명령 npm versionnode -v.

적절한 경우 :

  1. NPM의 루트 글로벌 디렉토리를 찾으 npm root -g십시오 (글로벌 npm 스토어의 루트를 제공합니다).

  2. 와 제거 된 각 CLI npm uninstall -g angular-clinpm cache clean

  3. 새 버전의 앵귤러 재설치 npm install -g @angular/cli@latest

  4. 이름 ng의 별칭 만들기 :

alias ng="C:/ProgramData/npm/node_modules/@angular/cli/bin/ng"

alias ng="<ath-to-your-global-node-modules>/<angular cli path till ng>"
(@ m.zemlyanoi @ m.zemlyanoi 15:30에 10 월 20 '16에 답변)

그런 다음 확인하려면 ng -v를 입력하십시오.


%AppData%\npmWin 경로에 추가 하는 것이 저에게 효과적이었습니다.

출처 : https://github.com/angular/angular-cli/issues/1183 , 첫 번째 댓글.


Node js 패키지를 설치합니까? https://nodejs.org/en/ 감사합니다


angular-cli를 설치할 때이 오류를 발견하면 -bash: ng: command not found작동합니다.

시스템에서 노드를 제거한 후

install NVM from here https://github.com/creationix/nvm
Install Node via NVM: nvm install stable
run npm install -g angular-cli

프로젝트를 생성하기 전에 angular-cli 가 설치되어 있는지 확인하십시오 . Windows 사용자는 명령에 대한 권한을 부여하지 않고 angular-cli설치할 수 있지만 MAC 사용자는 다음과 같이 명령을 실행하기 전에 sudo 를 사용해야합니다 .

sudo npm install -g angular-cli

요청시 암호를 입력하고 Enter 키를 눌러 계속합니다.


Windows 10 x64 / NodeJS 6.9.1 / npm 3.10.9를 실행하는 동일한 문제 입니다.
npm을 통해 Angular CLI를 설치 한 후 :

'ng'명령을 찾을 수 없습니다.

다음을 수행하십시오.

  1. npm 제거 npm uninstall -g npm
  2. Uninstalled NodeJS via control panel / programs and features
  3. Downloaded and ran 'old' NodeJS installer release 6.5.0 from https://nodejs.org/download/release/v6.5.0/ (node-v6.5.0-x64.msi).
  4. After NodeJS 6.5.0 installation completed, open powershell and npm install -g angular-cli
  5. Grab quick coffee
  6. After installation completed, ng worked OK.

HTH


According to npm, the angular-cli has been renamed to @angular/cli you can use the following syntax to install it.

npm install -g @angular/cli

soluton for windows operating system only....... first step:

install nodejs version: nodev 8.1.2

second step: set up environment variable like: C:\ProgramFiles\nodejs

Third step: install angular use this command: npm install -g @angular/cli

after installation whereever you have to create project like: ng new first-project......


For me (on MacOSX) I had to do:

nvm install stable
npm install -g angular-cli

This installed ng into:

/usr/local/lib/node_modules/@angular/cli/bin/ng

But npm did not put a link to ng into

/usr/local/bin/

Which was why it was not part of the %PATH and therefore available from the command line except via an absolute address.

So I used the following the create a link to ng:

sudo ln -sf /usr/local/lib/node_modules/\@angular/cli/bin/ng /usr/local/bin/ng

For Mac users:

1) Install @angular/cli globally

$ sudo npm install -g @angular/cli
/usr/local/Cellar/node/10.0.0/bin/ng -> /usr/local/Cellar/node/10.0.0/lib/node_modules/@angular/cli/bin/ng

2) Create alias for ng

alias ng="/usr/local/Cellar/node/10.0.0/lib/node_modules/@angular/cli/bin/ng"

Done


try this :

alias ng="~/node_modules/@angular/cli/bin/ng"


If you are working in windows 7 and you can not run command start with ng

please, update the angular/CLI at once and try to use ng commands

use below comman to update latest CLI

npm install -g @angular/cli@latest

This works to update your angular/cli //*Global package (cmd as administrator)

npm uninstall -g @angular/cli
npm cache verify
npm install -g @angular/cli@latest

Firstly install '@angular/cli' by using npm as global module

sudo npm install -g @angular/cli

After that try to ping the cli by using 'ng' command from the terminal window.If any problem like

Command 'ng' not found

Then you need to manually setup the

ng

command availability.You set this step by running the following command.

ln -s path-to-your-ng-command /bin

eg:

sudo ln -s /opt/node/lib/node_modules/@angular/cli/bin/ng /bin/


In my case, it was happening when I restarted working on an adjacent tab. It was the npm which was not set. Please check the version of npm wither using

npm -v

or if you are having nvm then

nvm list

or

nvm current

I set it to 8.9.1 and then it started working again. I hope it helps.


This worked for me:

  1. Go to C:\Users{{users}}\AppData\Roaming and delete the npm folder
  2. Uninstall node and install it again
  3. Run the command to install angular cli

    npm install -g @angular/cli
    

In my case, I was simply running the wrong node version.

I had just previously installed a new node version to play around with Angular (2). At work we use 6.x so that is my default in nvm. After restarting the laptop ng stopped working simply because I was running node 6.x again. So for me it was simply a matter of using the version with which I was installing the Angular CLI:

nvm use node // with the node alias pointing to the right version

or

nvm use v8.11.3 // if you happen to know the version

Check your installed versions and aliases with

nvm list 

If you have a MacOS computer (mine is MOJAVE 10.14.2), just add these lines to the end of your ~/.bash_profile file:

export ANGULAR=~/.nvm/versions/node/v10.8.0/bin/ng
export PATH=$ANGULAR:$PATH

Notice that v10.8.0 is the version of my installed Node.js. To get which version is yours, run this:

node --version

When done, reload it via your terminal/bash:

cd ~
source .bash_profile

After doing these steps you should be able to run your ng binary file.


running

export PATH=$PATH:/c/Users/myusername/AppData/Roaming/npm 

helped.

실제 사용자 이름이 myusername 섹션에 있는지 확인하십시오.


Windows에서 NodeJS 설치를 복구하면 문제가 해결되었습니다.


zsh가 설치되어 있으면 홈 디렉토리의 .zshrc 파일에도 별칭을 추가하십시오.


나는 창문에서 같은 문제가 있었기 때문에 여기에 왔습니다. 이것에 대해 나를 가장 당황하게 만든 것은 Angular 4가 여기 저기 두드리는 이후 Node가 설치되어 있다는 것입니다. 그리고 충분히. 그게 내 문제였습니다. 노드를 업그레이드해야했습니다.

최신 버전을 설치하는 것만으로도 위의 단계를 수행하지 않고도 잘 작동했습니다.

참고 URL : https://stackoverflow.com/questions/37227794/ng-command-not-found-while-creating-new-project-using-angular-cli

반응형