88
 Error: Node Sass does not yet support your current environment: OS X Unsupported architecture (arm64) with Unsupported runtime (93)
 For more information on which environments are supported please see:
 https://github.com/sass/node-sass/releases/tag/v4.14.1
at module.exports (/Users/hhag/Desktop/test_gulp/node_modules/node-sass/lib/binding.js:13:13)
at Object.<anonymous> (/Users/hhag/Desktop/test_gulp/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Module.require (node:internal/modules/cjs/loader:1013:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (/Users/hhag/Desktop/test_gulp/node_modules/gulp-sass/index.js:166:21)
at Module._compile (node:internal/modules/cjs/loader:1109:14)

this error occures when I start to use gulp. is there a solution for using gulp-sass with apple m1? thanks

user1272597
  • 1,215
  • 3
  • 12
  • 15

13 Answers13

117

I also had issues installing node-sass on M1, and ended up using the opportunity to replace it with sass, as recommended on the LibSass deprecation notice.

https://sass-lang.com/blog/libsass-is-deprecated

If you’re a user of Node Sass, migrating to Dart Sass is straightforward: just replace node-sass in your package.json file with sass. Both packages expose the same JavaScript API.

As mentioned by @Ti Hausmann you can try with:

npm uninstall node-sass
npm install --save-dev sass

The replacement was completely smooth, it worked on M1, and I couldn't notice any performance impact locally or on the CI.

blackgreen
  • 34,072
  • 23
  • 111
  • 129
Danilo Moret
  • 1,580
  • 1
  • 10
  • 10
86

For npm > 6.9 you can switch your dependency to dart-sass/sass with just one line and from there just use sass as you would before.

npm install node-sass@npm:sass

m_kos
  • 1,609
  • 1
  • 9
  • 7
33

I think, you are using an M1 Mac. And node-sass currently doesn't support it natively. See: https://github.com/sass/node-sass/issues/3033

For now you can set target arch for running it through Rosetta with:

rm -rf node_modules
npm install --target_arch=x64
Murat Çorlu
  • 8,207
  • 5
  • 53
  • 78
19

I ran into the same error when developing a Vue.js project with node-sass. I worked around this issue by downgrading to Node version 14.

I’ve done this with n, a Node’s version manager application. See this answer: https://stackoverflow.com/a/50287454.

Check which node version you’re using

$ node -v 
v16.3.0

Install n

$ npm install -g n

Get list of available Node versions you can install

$ n ls-remote --all
16.3.0
16.2.0
..
15.14.0
15.13.0
..
14.17.0
14.16.1
..

Install Node version 14

$ sudo n install 14

Sebastian Hagens
  • 891
  • 1
  • 7
  • 11
  • 2
    +1, Bear in mind if one had a previous installation of node using brew, one will have to uninstall the brew's node with `brew uninstall node` so the `n` node version takes effect – yeyo Feb 21 '22 at 17:28
  • I don't want to downgrade node version, is there no other way to fix this? – Bilal Hussain Aug 26 '22 at 07:16
6

Just adding for completeness of the answer, that I came across this issue when using the serverless framework (https://www.serverless.com/).

I was receiving a node gyp build error using both Node 16 and 17.

Using nvm I installed node version 14 and this solved my issue.

The steps to fix were:

  1. nvm install v14
  2. nvm use 14

Then I was able to do a yarn command which installed and built correctly.

Andre DiCioccio
  • 1,191
  • 1
  • 8
  • 10
5
  1. yarn add sass or npm install sass
  2. replace "node-sass": with "sass": in package.json
  3. rm -rf node_modules && npm install

Worked for me on my M1 MBP.

Vlad R
  • 1,851
  • 15
  • 13
4

Here is the official recomendation per gulp-sass Issue #803 - Apple M1 Chip Support

Switch to the sass compiler: Instructions

TL;DR:

  1. Install version 5 of node-sass that does not include a default Sass compiler:

npm install sass gulp-sass --save-dev

or, Yarn

yarn add sass gulp-sass --save-dev

  1. Explicitly set your compiler in your gulpfile:

const sass = require('gulp-sass')(require('sass'));

or, for ES6 modules

import gulpSass from 'gulp-sass';
const sass = gulpSass(dartSass);
Lindauson
  • 2,963
  • 1
  • 30
  • 33
3
  1. Reinstall node to version 14 by downloading from here https://nodejs.org/dist/v14.0.0/
  2. in your project folder run npm rebuild node-sass
Nik B
  • 617
  • 6
  • 11
2

Switching to Sass works just great in m1. As pointed in the top answers. And we should always be using sass in place of node-sass now as it's deprecated.

Here I want to point to one case that some may fall in. That if it's the case I think that would save you some time.

Case

You go and remove node-sass through npm uninstall or even by doing npm install node-sass@npm:sass as pointed in the second answer. You removed node-modules and package-lock.json.
And still having the same problem and somehow node-sass is getting compiled.

Not working even after trying to install sass?

If so the case. Make sure to check your dependencies versions. A good chance some of them depends on node-sass on there old versions.

Ex:

    "sass-loader": "^8.0.2",
    "styles-loader": "^1.0.2"

update the version to latest =>

    "sass-loader": "^12.4.0",
    "styles-loader": "^3.0.0"

That should do it. And make sure to check all the dependencies that can depend on node-sass and update them.

If for some reason that still is a problem. You can try adding

  "optionalDependencies": {
    "node-sass": "*"
  }

to package.json. I don't think it's necessary though.

Salim Djerbouh
  • 10,719
  • 6
  • 29
  • 61
Mohamed Allal
  • 17,920
  • 5
  • 94
  • 97
1

I have struggle lot with issue my my brand new macOS Monterey M1 Chip Macbook Pro. None of solutions work except It's fix when I have set target arch for NPM installation using below command.

npm install --target_arch=x64
Himanshu Patel
  • 172
  • 2
  • 8
0

This command worked for me,

npm uninstall node-sass -g && npm cache clean -force && npm install node-sass
Thushara Buddhika
  • 1,652
  • 12
  • 14
0

Yarn:

yarn remove node-sass
yarn add node-sass --dev
ckhatton
  • 1,359
  • 1
  • 14
  • 43
0

Use this guide - https://github.com/dlmanning/gulp-sass#setting-a-sass-compiler. It helped me a lot. Just make sure in the end that gulp-sass version is greater than 5.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 07 '23 at 18:46