LoginSignup
0
0

More than 1 year has passed since last update.

pnpmでpackage.jsonのscriptsに引数を渡す方法

Posted at

結論

明示的に環境変数を設定する1

package.json
{
  "scripts": {
    "hello": "echo Hello, $name!"
  }
}
$ name=World pnpm hello

> echo Hello, $name!

Hello, World!

補足: npmの場合

npmの場合は、次のように書いてコマンドライン引数に渡すことができます2

package.json
{
  "scripts": {
    "hello": "echo Hello, $npm_config_name!"
  }
}
$ npm run hello -name World

> echo Hello, $npm_config_name!

Hello, World!

引数の渡し方は下記のいずれでもOKです:thumbsup:

  1. -name World
  2. -name=World
  3. --name World
  4. --name=World
  1. npm との違い

  2. package.jsonのscriptsに引数を渡す方法

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