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.

[自分用]npm -gしたくないとき

Posted at

例えばvue-cliをプロジェクト単位で入れたいとする。

npm i --save-dev vue-cli

でインストールしちゃう

入れたモジュールのパスは
node_modules/.bin
に叩けるコマンド名でファイルが入ってます。
これを
$(npm bin)
こうも書けます。

コマンドが使えるように、package.jsonのscriptsの部分を編集します。

package.json
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "vue": "$(npm bin)/vue -V",
    "contentful": "$(npm bin)/contentful"
  },

scriptsは
npm run
で走らせることができます。

上のpackage.jsonの記述でnpm run vueをすると
vue-cliのバージョンが返ってきます。

"create": "$(npm bin)/vue init nuxt/starter ."

してカレントディレクトリにnuxtインストールしたら
書いてたscripts全部消えた泣くTT
追記した。
こうやってプロジェクト作っていくんかな

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?