Problem/Motivation
I see errors when running npm install on the generated subtheme. From the error, it seems that this is specific to the M1 (Apple Silicon) machines. As far as I can tell, the error is to do with node-sass and I have seen this happen before on M1 machines.
Steps to reproduce
On a M1 machine, follow the instructions to download the theme (^5.0) and run the create_subtheme.sh script. In the generated theme, run npm install. Eventually, the installation fails with a long sequence of error messages. Here is a snippet.
npm ERR! gyp info spawn make npm ERR! gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ] npm ERR! In file included from ../src/libsass/src/ast.cpp:2: npm ERR! ../src/libsass/src/ast.hpp:1614:25: warning: loop variable 'numerator' creates a copy from type 'const std::string' [-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 'const std::string &' 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 'const std::string' [-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 'const std::string &' to prevent copying npm ERR! for (const auto denominator : denominators) npm ERR! ^~~~~~~~~~~~~~~~~~~~~~~~ npm ERR! & npm ERR! 2 warnings generated.
This repeats several times for different file names where this file gets included.
Proposed resolution
Use the updated release of gulp-sass with the supported release of sass package.
Remaining tasks
Write a patch
User interface changes
None
API changes
We would also need to change gulpfile.js to use the updated gulp-sass package.
Data model changes
Issue fork bootstrap_sass-3259490
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
hussainwebCreated an MR with the basic changes. See https://git.drupalcode.org/project/bootstrap_sass/-/merge_requests/5.
With these changes,
npm installworks now. However, it shows deprecation notices for a few other packages. Would you rather I create a new issue for that or push updates here? FWIW, I updated all packages in my custom theme (and other improvements). Everything works well.Comment #4
emilcarpenter commentedPatch #2 works also for Ubuntu 20.04 LTS
Patch #2 makes
npm installwork without errors (but with deprecation and vulnerability messages) also on Ubuntu 20.04 LTS.Tested with:
Node v16 is currently the Active LTS version.
(On Ubuntu 20.04 the errors were different than in this issue.)
Comment #5
emilcarpenter commentedComment #6
hussainwebThanks for testing this, @emilcarpenter. I thought these errors were specific to M1 (I have seen similar errors before) but it seems they happen generally.
As for deprecations, I have avoided that by upgrading other packages as well. I am not sure if the maintainers would prefer to do them in a different issue or this one and that's why I didn't put those changes here. In this MR, I am only including minimal changes to get
npm installto work properly.Comment #7
emilcarpenter commentedThe errors were of different kind on Ubuntu. Good though, that your patch made
npm installwork also on Ubuntu!The minimal working approach is probably a good idea. It implies less testing and thereby less time expenditure for the maintainers. Maybe upgrading other packages would also need code changes in the bootstrap_sass module.
I guess it would be a better idea to create a separate issue for updating all packages. That way the Category, Priority, Status etc flags can be set here for 'getting it working at all' and in the other issue for the 'upgrade-all case' and also discussion about needs of code changes in this Drupal module, if any.
Comment #8
hussainwebFor the record, I didn't notice anything I had to change to get the theme to look okay after all the upgrades. I do notice some deprecations though which should be a different issue to fix. But there's nothing broken as far as I can see.
Comment #9
emilcarpenter commentedThanks, good to know!
Then maybe you could post that patch here in this issue. I would test it too and report back. That way the maintainers could choose to use that new patch or the patch from #2, as they like.
Maybe also change the Title (to point to the issue core and to get more attention from the maintainers) to something like:
npm install fails - with Active LTS version v16 of Node
Quote from Node Releases page:
Comment #10
hussainwebGood tip on the title. Thanks! As for the other change, I'll try to get to it soon but I hope to hear from one of the maintainers before doing more work. If they prefer another issue, I'll have to repeat some of the steps and I'd rather do this only once.
Comment #11
hussainwebMeanwhile, here's the `devDependencies` from my package.json. I hope this helps you in testing at least.
Comment #12
emilcarpenter commentedThanks for the new versions! I tested them and everything worked the same as with #2 patch.
I was hoping that the incredibly slow 'styles' task would quicken up, but it did not.
Comment #13
makesburbulis commentedTo speed up ‘styles’ step you can try to move autoprefixer gulp pass into post-css sub task - it will process css as one pass along with other post-css plugins…
But I have not seen it radically improved in speed…. And requires more bumps in devDependancy versions.
My current ‘style’ task run for 12 seconds on free layer of CircleCI pipes… but my overrides are pretty simple.
Comment #14
emilcarpenter commentedThanks Maxim!
My styles function went down from 22 seconds to 15-17 seconds.
Of course, it is still way too long time. Would be nice to get it down to a second or so.
I moved the autoprefixer like this:
I tried with fewer browsers also, but the 'styles' did not get faster.
Comment #15
brightbold+1 for the patch in #2. This also solved my problem with a failed installation.
Comment #16
lisag789 commentedThank you - patch #2 also fixed my problem installing on a new m1 mac
Comment #17
ultimikeSame here patch #2 worked for me, also on an M1 Mac.
The main difference is some deprecation warnings, most similar to:
These appear to be changes that will need to be made in bootstrap_barrio's sass files - seems like a great issue for a newbie :)
-mike
Comment #18
vistree commentedPath #2 also fixed problems on my mac (no M1) with Big Sur installed
Comment #19
mducharme commentedI ran into this on a new non-M1 mac using DDEV. Node v16 is installed by default. Fix was to add the following line to my .ddev/config.yml:
nodejs_version: "14"
Restarted the project and ran though install commands again and it worked for an existing theme.
Comment #20
zydoon commentedHi,
on Fedora 36
Python 3.10
Node 18
patch #2 solved the issue
and npm install works fine
Comment #21
jabberwooki commentedPatch #2 worked for me on my Ubuntu 20.04 dev laptop with
node v16.14.2
npm v8.5.0
Thanks to @hussainweb !
Comment #22
ivansb@drupal.orgAny chances this finally get merged and can be installed via composer?
thanks
Comment #24
kburakozdemir commented+1 Patch #2 works also for Ubuntu 20.04 LTS node version 16.16.0. Thank you.
Comment #25
hatuhay commentedComment #27
vistree commentedHi, I try to get gulp running on a Mac M3. I tried the old approach using patch from #2. But I can't get it to work.
Can anyone give a quick step by step on how to make gulp work on a Mac with M3 processor?
NPM version?
NODE version?
Python version?
...
Thank you so much!