sass / dart-sass

The reference implementation of Sass, written in Dart.
https://sass-lang.com/dart-sass
MIT License
3.97k stars 360 forks source link

Build Errors with Latest Sass Version in GitHub Actions CI/CD Pipeline #2186

Closed FareedGuru closed 7 months ago

FareedGuru commented 8 months ago

Hello Sass Team,

I've recently encountered build errors in my GitHub Actions CI/CD pipeline that seem to be related to the latest updates to Sass (as of 2 days ago). These errors were not present before the update. Here's a brief overview of the issues:

"sass": "^1.37.5", "sass-loader": "8.0.0",

I've verified that these issues are consistent across all runs in the last two days and are not present in my local development environment or in previous builds before the latest Sass update.

Any guidance on resolving these issues or information on recent changes that might affect the build process would be greatly appreciated.

Errors: 1: Module not found: Error: Can't resolve 'node-sass' in '/home/runner/work/ATS-Frontend-V2/ATS-Frontend-V2/node_modules/sass-loader/dist' @ ./node_modules/sass-loader/dist/getDefaultSassImplementation.js @ ./node_modules/sass-loader/dist/getSassImplementation.js @ ./node_modules/sass-loader/dist/index.js @ ./node_modules/sass-loader/dist/cjs.js @ ./app/components/NewCandidate/index.js @ ./app/components/TransferCand/SearchApplicants.js @ ./app/components/index.js @ ./app/containers/Pages/ShiftCalculation/index.js @ ./app/containers/pageListAsync.js @ ./app/containers/App/PerDiem/Facility.js @ ./app/containers/App/index.js @ ./app/app.js @ multi ./node_modules/react-app-polyfill/ie11.js ./app/app.js

2: ERROR in ./node_modules/sass/sass.node.js Module not found: Error: Can't resolve 'module' in '/home/runner/work/ATS-Frontend-V2/ATS-Frontend-V2/node_modules/sass' @ ./node_modules/sass/sass.node.js 7:14-31 @ ./app/components/Common/Modal.js @ ./app/containers/Pages/ShiftCancel/index.js @ ./app/containers/pageListAsync.js @ ./app/containers/App/PerDiem/Facility.js @ ./app/containers/App/index.js @ ./app/app.js @ multi ./node_modules/react-app-polyfill/ie11.js ./app/app.js

Thank you for your support and the great work on Sass!

nex3 commented 8 months ago

The first error here is related to node-sass, which is a different (deprecated) project.

The second error looks like it's failing to load the node:module module. We did add a load of this module recently for CLI apps, but that module has been present in Node.js since v12 so I don't know why your app is having trouble with it.

What version of Node.js are you using? Do you have a stand-alone reproduction of this error, ideally without sass-loader?

sbertault commented 8 months ago

I face the same problem on my own computer (node 16.18.1 on Debian Linux) and in the CI (node 16, ubuntu docker image I think). The "module" package is required¹, but not declared in the dependencies section of package.json. Had to add it manually. I am far from being a node specialist, but I'm under the impression that "module" (embedded in Node) is available in the global scope and one shouldn't "require()" it (I also came across the syntax require("node:module"))

¹ line 7 of sass.node.js : nodeModule: require("module")

nex3 commented 8 months ago

The globally-available module object is different from the module module. Although you can use the node: prefix to load built-in modules, it's not necessary. I've verified that console.log(require("module")) works as expected in Node 16.18.1 on my machine. Can you try running that exact script with the node CLI in the environment where you're seeing failures and report the result?

sbertault commented 7 months ago

@nex3 Indeed console.log(require("module")) does work as intended in both node interpreter and node script (launched directly from terminal or via npm in a sandbox project). I don't know what piece of context makes it different here. My failing project uses vue2 cli typescript and babel FWIW

nex3 commented 7 months ago

I'd recommend trying to strip out each of those components one by one until you figure out exactly which tool is causing this error, and then filing an issue against that tool.

guorun commented 7 months ago

please just check your .vue files. which file use some lines like

import * as sass from 'sass'

or import { types } from 'sass' or any lines want to import sass module then delete them and try again . I met same problems like you faced (node 16.20.2 on Linux) It looks like this

 This dependency was not found:

* module in ./node_modules/sass/sass.node.js

To install it, you can run: npm install --save module

and I found something... like import wrong packages in one .vue file and fix this problem. @sbertault

sbertault commented 7 months ago

Thanks a lot @guorun ; you nailed it. Someone mistakenly imported {Exception} from "sass" in a vue file. Just removed it, and upgrading to 1.71.1 or 1.72.0 now passes the build.