<環境>
OS: macOS Mojave バージョン 10.14.2
ターミナル: iTerm2
node: 10.15.1
npm: 6.8.0
nodebrewを使用しています
<起きている問題・解決したいこと>
npm -g install <パッケージ名>としたとき、一部のパッケージは正常にインストールに成功するのですが、一部のパッケージではインストールは成功しているにも関わらず、バージョンを表示しようとしてもエラーが出てしまいます。
例えば、以下のようにhttp-serverをインストールしたときはちゃんとバージョンが表示されますが、vueをインストールした後、vueのバージョンを表示しようとしたところでエラーが出てしまいます。
そこで、npmでインストールしたパッケージは全て使用できる(=コマンドが見つからない、などのエラーが出ない)状態にしたいです。
~$ npm install -g http-server /Users/MyUserName/.nodebrew/node/v10.15.1/bin/http-server -> /Users/MyUserName/.nodebrew/node/v10.15.1/lib/node_modules/http-server/bin/http-server /Users/MyUserName/.nodebrew/node/v10.15.1/bin/hs -> /Users/MyUserName/.nodebrew/node/v10.15.1/lib/node_modules/http-server/bin/http-server + http-server@0.11.1 added 26 packages from 28 contributors in 2.009s ~$ http-server -v Starting up http-server, serving ./public Available on: http://127.0.0.1:8080 http://192.168.100.104:8080 http://192.168.33.1:8080 http://192.168.99.1:8080 Hit CTRL-C to stop the server ^Chttp-server stopped. ~$ npm install -g vue + vue@2.6.6 added 1 package from 1 contributor in 0.642s ~$ vue -V zsh: command not found: vue
<今回の問題に関係があるかもしれない思ったところ>
npmでインストールされたパッケージの保存先として、http-serverは
~/.nodebrew/current/bin
と
~/.nodebrew/current/lib/node_modules
の2箇所に記述がある(前者のディレクトリから後者のディレクトリにシンボリックリンクが貼られている)のですが、
vueの場合は
~/.nodebrew/current/lib/node_modules
の方にしか保存されていません。(以下のコードのようになっています)
~$ ls -la ~/.nodebrew/current/bin total 78024 drwxr-xr-x 8 MyUserName staff 256 2 16 14:54 . drwxr-xr-x 9 MyUserName staff 288 2 14 23:12 .. lrwxr-xr-x 1 MyUserName staff 47 2 16 14:54 hs -> ../lib/node_modules/http-server/bin/http-server lrwxr-xr-x 1 MyUserName staff 47 2 16 14:54 http-server -> ../lib/node_modules/http-server/bin/http-server -rwxr-xr-x 1 MyUserName staff 39945984 1 29 16:18 node lrwxr-xr-x 1 MyUserName staff 39 2 14 23:13 nodebrew -> /Users/MyUserName/.nodebrew/nodebrew lrwxr-xr-x 1 MyUserName staff 38 2 14 23:13 npm -> ../lib/node_modules/npm/bin/npm-cli.js lrwxr-xr-x 1 MyUserName staff 38 2 14 23:13 npx -> ../lib/node_modules/npm/bin/npx-cli.js ~$ ls -la ~/.nodebrew/current/lib/node_modules total 0 drwxr-xr-x 5 MyUserName staff 160 2 16 14:54 . drwxr-xr-x 4 MyUserName staff 128 2 14 23:12 .. drwxr-xr-x 8 MyUserName staff 256 2 16 14:54 http-server drwxr-xr-x 25 MyUserName staff 800 2 14 23:13 npm drwxr-xr-x 8 MyUserName staff 256 2 16 14:28 vue
また、この後npm install -gによってexpressとyarnをインストールしてみました。すると、どちらもインストール自体は問題なく完了したのですが、バージョン表示をしようとすると、expressの方は「zsh: command not found: express」とエラーになりましたが、yarnの方は「1.13.0」と、バージョンが表示されました。
なぜ同じインストール方法をしているにも関わらずパッケージごとに挙動が異なるのか意味がわからないです。
ご回答、よろしくお願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/16 06:38
2019/02/16 07:08