Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,9 @@ endif
pkgbuild --version $(FULLVERSION) \
--identifier org.nodejs.node.pkg \
--root $(MACOSOUTDIR)/dist/node $(MACOSOUTDIR)/pkgs/node-$(FULLVERSION).pkg
mkdir -p $(MACOSOUTDIR)/dist/npm/usr/local/bin
ln -sf ../lib/node_modules/npm/bin/npm-cli.js $(MACOSOUTDIR)/dist/npm/usr/local/bin/npm
ln -sf ../lib/node_modules/npm/bin/npx-cli.js $(MACOSOUTDIR)/dist/npm/usr/local/bin/npx
Comment on lines +1179 to +1181
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't seem correct, we don't want to install those on the release machine

Suggested change
mkdir -p $(MACOSOUTDIR)/dist/npm/usr/local/bin
ln -sf ../lib/node_modules/npm/bin/npm-cli.js $(MACOSOUTDIR)/dist/npm/usr/local/bin/npm
ln -sf ../lib/node_modules/npm/bin/npx-cli.js $(MACOSOUTDIR)/dist/npm/usr/local/bin/npx

Copy link
Author

@sdavids sdavids Mar 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can either place these files on the release machine before invoking pkgbuild and then they are inside the package and no postinstall is needed or you need the postinstall script.

One could remove them right after the pkgbuild though.

Copy link
Author

@sdavids sdavids Mar 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also unsure what you mean by "release machine".

These symlinks are created inside the build folder out which is gitignored.

$ tree --noreport out/macos/dist/npm/usr/local/bin
out/macos/dist/npm/usr/local/bin
├── npm -> ../lib/node_modules/npm/bin/npm-cli.js
└── npx -> ../lib/node_modules/npm/bin/npx-cli.js
$ tree --noreport out/macos/pkgs 
out/macos/pkgs
├── node-v24.0.0.pkg
└── npm-v11.2.0.pkg
$ pkgutil --expand out/macos/pkgs/node-v24.0.0.pkg /tmp/node 
$ pkgutil --expand out/macos/pkgs/npm-v11.2.0.pkg /tmp/npm
$ tar -tvf /tmp/node/Payload | grep './usr/local/bin'        
drwx------  4 0      0           0 Mar 30 22:15 ./usr/local/bin
-rwx------  1 0      0   231691704 Mar 30 22:15 ./usr/local/bin/node
lrwx------  1 0      0          45 Mar 30 22:14 ./usr/local/bin/corepack -> ../lib/node_modules/corepack/dist/corepack.js
$ tar -tvf /tmp/npm/Payload | grep './usr/local/bin' drwx------  4 0      0           0 Mar 30 22:39 ./usr/local/bin
lrwx------  1 0      0          38 Mar 30 22:39 ./usr/local/bin/npx -> ../lib/node_modules/npm/bin/npx-cli.js
lrwx------  1 0      0          38 Mar 30 22:39 ./usr/local/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js

Note: The lrwx------ is due to my machine having umask 022; on a regular build machine it will be lrwxr-xr-x.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the unlink call to after invocating pkgbuild sounds like a better solution

Copy link
Author

@sdavids sdavids Mar 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npx

The unlinks are for the npm and npx symlinks in the node and not the npm directory; these would have been placed in the org.nodejs.node.pkg package—the reason being that they won't end up in the package and will not get extracted to /usr/local/bin on the machine the installer is executed on.

The symlinks created by this PR will be placed in the org.nodejs.npm.pkg package and thereby the installer will extract them into /user/local/bin with the correct permissions and user/group.

One could add 2 additional unlink statements for npm and npx after the pkgbuild though.

But I am not sure if it is worth it: Aren't these links in an ephemeral directory on a build machine?

pkgbuild --version $(NPMVERSION) \
--identifier org.nodejs.npm.pkg \
--root $(MACOSOUTDIR)/dist/npm \
Expand Down
5 changes: 0 additions & 5 deletions tools/macos-installer/pkgbuild/npm/scripts/postinstall

This file was deleted.