Email or username:

Password:

Forgot your password?
Axel Rauschmayer

Using variables in npm run scripts (package (a)rauschma/env-var must be installed locally or globally):

{
"scripts": {
"hi": "env-var echo {{npm_package_config_hi}}"
},
"config": {
"hi": "HELLO"
}
}

Works on Windows and Unix:
npm run hi

More information: exploringjs.com/nodejs-shell-s

#NodeJS

1 comment
Braw ☕🏳️‍🌈

@rauschma if you are using pnpm, there's `shell-emulator` configuration option: pnpm.io/cli/run#shell-emulator. It lets you `DEFINE_ENVS=before script` like you'd do in regular POSIX shell. Yarn does use it by default. Kinda wish npm adopted that (probably as an option, to stay backwards compatible).

Go Up