Search code examples
node.jsnpmsassgulp-sass

Sass - TypeError: Cannot read properties of undefined (reading 'indexOf')


My build on the server failed today, suddenly, when doing its Sass thing it's always done for 4 years.

It runs in Docker so the image probably has a later npm than I have locally, since I don't tend to update things that work.

So I updated my local node and npm and replicated the issue.

TypeError: Cannot read properties of undefined (reading 'indexOf')
    at /Users/me/myCode/node_modules/sass/sass.dart.js:116832:12
    at Object.applyHooksTransformer (/Users/me/myCode/node_modules/sass/sass.dart.js:1863:14)
    at Object.initHooks (/Users/me/myCode/node_modules/sass/sass.dart.js:1843:251)
    at Object.initNativeDispatchContinue (/Users/me/myCode/node_modules/sass/sass.dart.js:1809:9)
    at Object.initNativeDispatch (/Users/me/myCode/node_modules/sass/sass.dart.js:1803:9)
    at Object.getNativeInterceptor (/Users/me/myCode/node_modules/sass/sass.dart.js:29308:13)
    at Object.getInterceptor$x (/Users/me/myCode/node_modules/sass/sass.dart.js:29569:16)
    at Object.set$compile$x (/Users/me/myCode/node_modules/sass/sass.dart.js:29636:16)
    at Object.main (/Users/me/myCode/node_modules/sass/sass.dart.js:24401:9)
    at main2 (/Users/me/myCode/node_modules/sass/sass.dart.js:26210:9)
  • I've "gone up" through some major versions of both sass and gulp-sass but even latest doesn't work.
  • I've cleared the cache and reinstalled these packages.
  • I use Sass to build Bootstrap and a single custom.scss file.
  • I have not yet checked-out an old commit from Git.
  • It last built on Weds 18th Oct and it's now Mon 23rd.
  • I've been working far from any of this in C# code.
  • I've had only 4 hours sleep and this error showed up on a bad day for me.
  • AI is out of ideas.

The failure is spontaneous and unexpected.

My guess is that the Node Docker image was updated this weekend and this has broken Sass somehow.

Updates

  • The official Node docker image was updated..... 4 days ago.

Solution

  • Looks exactly like an error I just spotted yesterday. Check the version of node you are using in the docker image, if it's 21 or current just downgrade to 20.

    Looks like a common issue already: https://github.com/vercel/next.js/issues/57005