
Its top level looks like this: npm_package_json: '/Users/robin/new-package/package.json', The prefix npm_package_ gives us access to the contents of package.json. Npm_config_user_agent: 'npm/8.15.0 node/v18.7.0 darwin arm64 workspaces/false', Npm_config_local_prefix: '/Users/robin/new-package', Npm_config_globalconfig: '/usr/local/etc/npmrc', These are a few examples: npm_config_cache: '/Users/robin/.npm', Under prefix npm_config_, we can see some of npm’s configuration settings ( which are described in the npm documentation).

On Windows, npm_lifecycle_script would SET in this case. Under npm_lifecycle_, we find the name and the definition of the currently running package script: npm_lifecycle_event: 'env', The npm_ variables have a hierarchical structure. Let’s only print those, in alphabetical order: npm run env | grep npm_ | sort The names of all of npm’s temporary variables start with npm_. Npm package scripts are defined via property "scripts" of package.json:

Shorter npm commands for running package scripts.In this blog post, we explore how that works and how we can write them in a way that works across platforms (Unixes and Windows). The npm package manager lets us define small shell scripts for tasks and execute them via npm run.
