4

so I am trying to get gulp to run on my M1 MacBook Pro with little success so far.

I have tried a whole bunch of things from deleting the package.json to trying to install with sudo but everything gives me this error.

gulp error message:

enter image description here

kian
  • 1,449
  • 2
  • 13
  • 21
Alex McIver
  • 47
  • 1
  • 7
  • Does this answer your question? [Node Sass with apple m1, Big Sur and arm64](https://stackoverflow.com/questions/68095626/node-sass-with-apple-m1-big-sur-and-arm64) – connexo Nov 16 '21 at 09:48
  • @connexo I have already tried everything in that post and nothing worked :( – Alex McIver Nov 16 '21 at 10:09
  • If you eradicate sass from the gulp equation, does gulp still not work? – connexo Nov 16 '21 at 10:10
  • @connexo why would I want to do that? – Alex McIver Nov 16 '21 at 10:15
  • Because I don't think gulp has any problem on M1, and that is what your question claims. Narrow down your problem to ask a more precise question. – connexo Nov 16 '21 at 10:16
  • Might you please [edit] your question to include your error messages and other textual content as **text** rather than as a screen shot? It's preferred not to use images for this purpose here, see [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/a/285557) and [Discourage screenshots of code and/or errors](https://meta.stackoverflow.com/q/303812) for why. – dbc Nov 20 '21 at 00:07

1 Answers1

1

This is what worked for me.

The solution was to change the architecture of my shell from arm64 to x86.

Macs with M1 chip

January 2021: there are no pre-compiled NodeJS binaries for versions prior to 15.x for Apple's new M1 chip (arm64 architecture).

Some issues you may encounter:

  1. using nvm to install, say, v14.15.4:
  • the C code compiles successfully
  • but crashes with an out of memory error when used
  • increasing the memory available to node still produces the out of memory errors: $ NODE_OPTIONS="--max-old-space-size=4096" ./node_modules/.bin/your_node_package
  1. when using nvm to install some versions, the compilation fails

One solution to this issue is to change the architecture of your shell from arm64 to x86.

Let's assume that:

  • you already have versions 12.20.1 and 14.15.4 installed using nvm
  • the current version in use is 14.15.4
  • you are using the zsh shell
  • you have Rosetta 2 installed (macOS prompts you to install Rosetta 2 the first time you open a Intel-only non-command-line application, or you may install Rosetta 2 from the command line with softwareupdate --install-rosetta)
//# Check what version you're running:
$ node --version
v14.15.4
//# Check architecture of the `node` binary:
$ node -p process.arch
arm64
//# This confirms that the arch is for the M1 chip, which is causing the problems.
//# So we need to uninstall it.
//# We can't uninstall the version we are currently using, so switch to another version:
$ nvm install v12.20.1
//# Now uninstall the version we want to replace:
$ nvm uninstall v14.15.4
//# Launch a new zsh process under the 64-bit X86 architecture:
$ arch -x86_64 zsh
//# Install node using nvm. This should download the precompiled x64 binary:
$ nvm install v14.15.4
//# Now check that the architecture is correct:
$ node -p process.arch
x64
//# It is now safe to return to the arm64 zsh process:
$ exit
//# We're back to a native shell:
$ arch
arm64
//# And the new version is now available to use:
$ nvm use v14.15.4
Now using node v14.15.4 (npm v6.14.10)

*source: Failed to "nvm install 8.0.0" source: https://github.com/nvm-sh/nvm

Roundy
  • 121
  • 1
  • 8