0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Angluar CLIをインストール後にngコマンドが見つからないと表示された場合

Posted at

Angluar CLIをインストールした後、ngコマンドを叩いたが「ng: command not found」と表示された場合の対処法

MacのターミナルからAngularのプロジェクトを作成するために、npmツールを使って、Angular CLIをインストールしました。

npm install -g @angular/cli

その後、ngコマンドを叩いたところ、下記のようなエラー(ngコマンドが見つからない)が表示されました。

mymac:test user$ ng
zsh: command not found: ng

aliasで一時的にPATHを通す

これは、ngコマンドを実行する際に、PATHが通ってないだけなので、AngularのCLIがインストールされた場所を確認して、以下のコマンドを実行します。

alias ng="/user/Desktop/angular/angular/.npm-global/lib/node_modules/@angular/cli/bin/ng"

これで、パスを通すことができます。

上記の「ng="〜"」は、インストールした場所によって変わるため、「npm install -g @angular/cli」を実行時にインストール場所がターミナルに表示されているはずなので、それを入力する必要があります。

TATHとは?

コマンドプロントであるフォルダを実行したい、例えばgitコマンドを実行したい場合、コンピュータはgitコマンドが何処にあるか、分かりません。なので、このフォルダを探してください = PATHで場所を指定することができます。

以上となります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?