Skip to Content
DocsutooLifecycle Scripts

Lifecycle Scripts

utoo runs the same set of npm lifecycle scripts from your package.json’s scripts field, in the same order npm uses. This page documents which hooks exist, what environment they run in, and how to skip them.

Install-time hooks

Run by ut install (and ut rebuild) for the project root:

HookWhen it runs
preinstallBefore dependencies are resolved
installDuring the install phase
postinstallAfter all dependencies are installed
preprepareBefore prepare
prepareAfter install, and before pack / publish
postprepareAfter prepare
prepublishLegacy alias for prepare (npm-compat)

Every dependency that declares these hooks also gets them run (subject to --ignore-scripts). To re-run the dependency install hooks without reinstalling, use ut rebuild.

Pack / publish hooks

Run by ut pm-pack and ut publish:

HookWhen it runsTriggered by
prepackBefore the tarball is assembledut pm-pack, ut publish
postpackAfter the tarball is assembledut pm-pack, ut publish
prepublishOnlyBefore publish (not during pm-pack)ut publish
publishDuring publishut publish
postpublishAfter successful publishut publish

Script environment

Every script utoo runs — lifecycle hook or user scripts entry — starts with this environment:

VariableValue
PATHAugmented with every node_modules/.bin on the path up to the project root, so package binaries resolve without npx.
npm_lifecycle_eventThe hook or script name (install, postinstall, build, …).
INIT_CWDAbsolute path to the directory where the triggering ut command ran.
npm_package_jsonAbsolute path to the current package’s package.json.
npm_config_global"true" when the install is global (-g), else empty.

In addition, when the active registry provides a binary-mirror config, utoo injects its ENVS block into the environment (e.g. ELECTRON_MIRROR, SASS_BINARY_SITE). These are visible to dependency install scripts so native modules pick up the right CDN automatically.

Skipping scripts

Disable all lifecycle scripts with --ignore-scripts. It works as a top-level flag that applies to whichever subcommand follows, or as a per-command option:

Terminal
# Global form — applies to any subcommand ut --ignore-scripts install ut --ignore-scripts rebuild # Per-command form ut install --ignore-scripts ut uninstall lodash --ignore-scripts

Use this when installing packages from an untrusted source, or when debugging whether a failure is caused by a script.

Automatic node-gyp

When utoo encounters a dependency that contains a binding.gyp file (the marker of a node-gyp native module), it checks PATH for node-gyp. If missing, utoo installs it globally once (ut install -g node-gyp) and proceeds. You never need to pre-install node-gyp manually.

The check and install run at most once per ut invocation — concurrent native-module installs share a single install.

  • ut rebuild — re-run dependency install hooks.
  • ut run — run an arbitrary script from package.json.
  • Registry Acceleration — for the binary-mirror envs injected into install scripts.
Last updated on