最終更新:2023-09-14 (木) 14:37:33 (307d)  

npm init
Top / npm init

Interactively create a package.json file

対話形式でprojectの初期設定を行う

https://docs.npmjs.com/cli/init

https://docs.npmjs.com/cli/v9/commands/npm-init?v=true

npm init <package-spec> (same as `npx <package-spec>`)
npm init <@scope> (same as `npx <@scope>/create`)

変換

  • The init command is transformed to a corresponding npm exec? operation as follows:
    npm init foonpm exec create-foo
    npm init @usr/foonpm exec @usr/create-foo
    npm init @usrnpm exec @usr/create
    npm init @usr@2.0.0npm exec @usr/create@2.0.0
    npm init @usr/foo@2.0.0npm exec @usr/create-foo@2.0.0

メモ

  • 対話的にpackage.jsonが生成される。
    {
      "name": "example",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "ISC"
    }

npm init <initializer>

  • <initializer> in this case is an npm package named create-<initializer>,

package.json

  • プロジェクトのパッケージを管理するためのファイル