Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mac Arm64 support for Node #20764

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion BuildConfigGen/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function detect_platform_and_runtime_id ()
fi

elif [[ "$CURRENT_PLATFORM" == 'darwin' ]]; then
DETECTED_RUNTIME_ID='osx-x64'
DETECTED_RUNTIME_ID="osx-$(uname -m)"
fi
}

Expand Down
10 changes: 8 additions & 2 deletions make-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,14 @@ var installNodeAsync = async function (nodeVersion) {
var nodeUrl = 'https://nodejs.org/dist';
switch (platform) {
case 'darwin':
var nodeArchivePath = await downloadArchiveAsync(nodeUrl + '/' + nodeVersion + '/node-' + nodeVersion + '-darwin-x64.tar.gz');
addPath(path.join(nodeArchivePath, 'node-' + nodeVersion + '-darwin-x64', 'bin'));
var arch = run('uname -m')
var nodeMajorVersionNumber = parseInt(nodeVersion.match(/\d+/)[0], 10);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add fallback for the case when parseInt failed for some reason.

if (nodeMajorVersionNumber < 16) { // arm64 support started since node16
arch = 'x64'
}

var nodeArchivePath = await downloadArchiveAsync(nodeUrl + '/' + nodeVersion + '/node-' + nodeVersion + '-darwin-' + arch + '.tar.gz');
addPath(path.join(nodeArchivePath, 'node-' + nodeVersion + '-darwin-' + arch, 'bin'))
break;
case 'linux':
var nodeArchivePath = await downloadArchiveAsync(nodeUrl + '/' + nodeVersion + '/node-' + nodeVersion + '-linux-x64.tar.gz');
Expand Down