In pnpm v10, the lifecycle scripts of dependencies no longer execute automatically during installation. Lifecycle scripts like preinstall, install, postinstall, etc., which were previously executed, now need to be manually specified using the onlyBuiltDependencies parameter if they are to run. For example:
{ "pnpm": { "onlyBuiltDependencies": ["fsevents"] }}
This change enhances security but also increases complexity for developers.
pnpm link Improvements
The pnpm link functionality has been updated. It now creates global packages by default, whereas previously pnpm link -g was required. In a workspace with multiple packages, the override option has been added to the root directory. This allows specifying a particular version of a dependency when multiple dependencies rely on different versions of the same package. For instance:
{ "dependencies": { "A": "^1.0.0", "B": "^2.0.0" }, "pnpm": { "overrides": { "lodash": "^4.17.21" } }}
It can also be used to replace a problematic dependency:
{ "dependencies": { "problem-package": "^1.0.0" }, "pnpm": { "overrides": { "problem-package": "my-forked-package@^1.0.1" } }}
Security Hash Upgrade
All hash algorithms in pnpm v10 have been updated to SHA256. This includes hashing the long paths in node_modules/.pnpm, the long peer dependency hashes in the lock file, the hashes stored in the packageExtensionsChecksum field of pnpm-lock.yaml, the side effect cache keys, and the pnpmfile checksums in the lock file.
Configuration Updates
manage-package-manager-versionsis now enabled by default, allowing pnpm to manage its own version based on thepackageManagerfield inpackage.json.public-hoist-patternno longer hoists certain packages (like those witheslintorprettierin their names) to the root ofnode_modulesby default.@yarnpkg/extensionshas been upgraded tov2.0.3, which may change thepnpm-lockfile.- On Windows, the default value of
virtual-store-dir-max-lengthhas been reduced to 60 characters, and fewernpm_package_*environment variables are set during script execution. Onlyname,version,bin,engines, andconfigare retained. - Even when
NODE_ENV=production, all dependencies (including development dependencies) are now installed. To install only production dependencies, usepnpm add --prod.
Global Store Changes
The global store has been upgraded to v10. The index file storage method has changed to use content hashes and package identifiers to accommodate different package names or versions of the same content. The integrity check of the lock file against the correct package is more crucial. A new index directory stores the package content mapping, and the index file structure is more efficient in tracking side effects by listing only file differences.
Other Notable Changes
- The
#character in directory names withinnode_modules/.pnpmis now escaped. - Running
pnpm add --global pnpmorpnpm add --global @pnpm/exenow fails and prompts for self-update. - Dependencies added via URL now record the final resolved URL in the lock file.
- The
pnpm deploycommand now only works with workspaces havinginject-workspace-packages=trueand creates or falls back to a deployment lock file as needed. - The conversion from
lockfile v6tov9has been removed. Usepnpm CLI v9for this conversion if required. pnpm testnow passes all parameters after thetestkeyword directly to the underlying script, consistent withpnpm run test.
Minor Changes
- Support for a new dependency type
configurational dependenciehas been added. These are installed before other types and require an exact version and integrity checksum. For example:
{ "pnpm": { "configDependencies": { "my-configs": "1.0.0+sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==" } }}
- A new setting
verify-deps-before-runcontrols how pnpm checksnode_modulesbefore running a script. - The
inject-workspace-packagessetting allows hard-linking of local workspace dependencies instead of symbolic linking. - Faster repeated installations are now possible with a quick check for the latest
node_modules. pnpm addintegrates with the default workspace directory.pnpm dlxresolves packages to their exact versions for caching.- Some commands no longer validate or clear
node_modulesif they shouldn't modify it.