I recently switched to a Mac with an M1 Pro chip and found that this chip conflicts with node-sass.
People with the same problem advise replacing packages from node-sass with sass or updating node and node-sass versions - unfortunately, I'm working with a legacy project and many packages are already deprecated, and in order to solve the problem in this way, the project has to go to refactoring, which does not solve the problem immediately.
npm rebuild node-sass - as I read, can solve the problem, so I'm aiming for this option right now.
But, with node 16.20.1 and node-sass 6.0.1 I keep getting the error:
2 warnings generated.
npm ERR! In file included from ../src/libsass/src/values.cpp:3:
npm ERR! In file included from ../src/libsass/src/values.hpp:4:
npm ERR! ../src/libsass/src/ast.hpp:1614:25: warning: loop variable 'numerator' creates a copy from type 'std::string const' [-Wrange-loop-construct]
npm ERR! for (const auto numerator : numerators)
npm ERR! ^
npm ERR! ../src/libsass/src/ast.hpp:1614:14: note: use reference type 'std::string const &' to prevent copying
npm ERR! for (const auto numerator : numerators)
npm ERR! ^~~~~~~~~~~~~~~~~~~~~~
npm ERR! &
npm ERR! ../src/libsass/src/ast.hpp:1616:25: warning: loop variable 'denominator' creates a copy from type 'std::string const' [-Wrange-loop-construct]
npm ERR! for (const auto denominator : denominators)
npm ERR! ^
npm ERR! ../src/libsass/src/ast.hpp:1616:14: note: use reference type 'std::string const &' to prevent copying
npm ERR! for (const auto denominator : denominators)
npm ERR! ^~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! &
npm ERR! 2 warnings generated.
npm ERR! env: python: No such file or directory
npm ERR! make: *** [Release/sass.a] Error 127
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/Users/valenty/project/node_modules/node-sass/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm ERR! gyp ERR! System Darwin 23.0.0
npm ERR! gyp ERR! command "/Users/valentyn/.nvm/versions/node/v16.20.2/bin/node" "/Users/valenty/project/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Users/valentyn/project/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.20.2
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
I tried to run the command with Rosetta and without already - it dosn't help.
UPD Updating the node-sass package solved the problem, and no major refactoring was required after updating to the latest version.
It looks like a bug in the
libsasslibrary; I would recommend reporting to them, or replacing the SASS implementation.See: https://github.com/sass/node-sass/issues/3184