最終更新:2023-10-06 (金) 15:25:58 (65d)
npm install
Top / npm install
Install a package
npm install npm install <package>
パラメータなし
- package.jsonに記載されたパッケージが一括でインストールされる
パラメータ
- The -g or --global argument will cause npm to install the package globally rather than locally. See npm help 5 npm-folders.
エイリアス
- add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall
フォルダ
ローカル
- npm bin
- Local install (default): puts stuff in ./node_modules of the current package root.
グローバル
- Global install (with -g): puts stuff in /usr/local or wherever node is installed.
- npm bin -g
C:\Users\<ユーザ名>\AppData\Roaming\npm
package.jsonへの追記
npm install
- npm install saves any specified packages into dependencies by default. Additionally, you can control where and how they get saved with some additional flags:
-P, --save-prod Package will appear in your dependencies. This is the default unless -D or -O are present. -D, --save-dev Package will appear in your devDependencies. -O, --save-optional Package will appear in your optionalDependencies. --no-save Prevents saving to dependencies.
昔
- パッケージリストに保存
- むかしはnpm install --saveとしていた
npm install <パッケージ名> --save
- By default with version npm 5.0+ npm install adds the module to the dependencies list in the package.json
npm install --save-dev
Ubuntuの場合
- sudo npm install -g <パッケージ>
バージョン指定
- npm install grunt@0.3.17
npm updateとの違い
npm install
- 未インストールのパッケージをインストール
- 指定より上バージョンのパッケージが存在してもインストールしない
npm update
- 未インストールのパッケージはインストールしない
- 指定より上バージョンのパッケージが存在すればインストールする