question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

node-sass not compatible with newer versions of node, such as 14 and 16

See original GitHub issue

Bug Report

I installed node version 14.17.5 (using nvm) and the wpgulp script does not complete a build uisng “npm start” anymore. Error: Cannot find module ‘fs/promises’ .

Apparently node-sass is deprecated and incompatible with the latest node versions.

Expected Behavior

Expected the script to complete.

Actual Behavior

Script produces error.

Steps to Reproduce

  1. switch to node 14.17.5
  2. run npm start
  1. node -v: 14.17.5
  2. npm -v: 6.14.14

Then, specify:

  1. Operating system: Ubuntu 18.04

Possible Solution find an alternate to node-sass? maybe dart-sass?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:6

github_iconTop GitHub Comments

2reactions
seanrasmussencommented, Dec 6, 2021

Hi @jeffceriello

If you’re getting a node-sass error, that’s because the new version of gulp-sass doesn’t include node-sass anymore. What you want to do is swap out node-sass, for plain ol’ sass.

Update your gulp-sass to the latest stable version.

Add sass to your project: npm install sass --save then change the line where you require sass in gulpfile.babel.js FROM

const sass = require('gulp-sass'); // Gulp plugin for Sass compilation. TO

const sass = require('gulp-sass')(require('sass')); // Gulp plugin for Sass compilation.

That brings in SASS, and the rest is the same. Note that for some things the sass package has some different options than node-sass, like for “compacted” vs “expanded” etc… So, follow the errors and make any changes required… I can’t remember off-hand what those changes are. I’ve been meaning to fork WPGulp and provide it publicly, but haven’t got around to it yet…

I hope that helps. I’ll try and fork the repo sometime soon and update this thread.

Note that on projects where I haven’t updated my gulp config yet, I just use NVM to switch to node 12 and WpGulp works like normal. That’s easier, and you may not need the latest version of Node for a WordPress project…

0reactions
shawnstom523commented, Apr 28, 2022

Hi @jeffceriello

If you’re getting a node-sass error, that’s because the new version of gulp-sass doesn’t include node-sass anymore. What you want to do is swap out node-sass, for plain ol’ sass.

Update your gulp-sass to the latest stable version.

Add sass to your project: npm install sass --save then change the line where you require sass in gulpfile.babel.js FROM

const sass = require('gulp-sass'); // Gulp plugin for Sass compilation. TO

const sass = require('gulp-sass')(require('sass')); // Gulp plugin for Sass compilation.

That brings in SASS, and the rest is the same. Note that for some things the sass package has some different options than node-sass, like for “compacted” vs “expanded” etc… So, follow the errors and make any changes required… I can’t remember off-hand what those changes are. I’ve been meaning to fork WPGulp and provide it publicly, but haven’t got around to it yet…

I hope that helps. I’ll try and fork the repo sometime soon and update this thread.

Note that on projects where I haven’t updated my gulp config yet, I just use NVM to switch to node 12 and WpGulp works like normal. That’s easier, and you may not need the latest version of Node for a WordPress project…

I tried updating to sass from gulp-sass per your recommendation and I still get the node-sass error

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js Sass version 7.0.0 is incompatible with ^4.0.0 || ^5.0.0
It's the sass-loader issue and that's the library you need to upgrade since older versions are not compatible with the newer node-sass ....
Read more >
node-sass - npm
Latest version : 8.0.0, last published: 2 months ago. Start using node-sass in your project by running `npm i node-sass`.
Read more >
Node 16 Upgrade
Preferably upgrade edx-owned dependencies to the Node 16 supported version. For some commonly used libraries, Node 16 supported versions are ...
Read more >
node sass does not yet support your current environment
support ; Node.js 16, upgrade gulp- ; sass: the latest version today is 5.1.0: npm install -D ; This will give you ;...
Read more >
Node Sass does not yet support your current environment
This problem happens because the version of node-sass that you have installed is no longer compatible with the version of node you are ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found