canirequire › CommonJS › node-sass
Is node-sass ESM-only? Can you require() it?
Wrapper around libsass
Latest version 9.0.0, published May 20, 2023. JSON
CommonJS CommonJS — require() works on every Node.js version
node-sass ships CommonJS only. require("node-sass") works everywhere. import "node-sass" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.
Deprecated: Node Sass is no longer supported. Please use `sass` or `sass-embedded` instead.
Does node-sass@9.0.0 actually load? Runtime test results
Runtime probe pending for this version. The values below are what package.json declares; they are refreshed once the probe runs.
| Runtime | require("node-sass") | import "node-sass" |
|---|---|---|
| Node.js 18 | ✓ expected | ✓ expected |
| Node.js 20 | ✓ expected | ✓ expected |
| Node.js 22 | ✓ expected | ✓ expected |
| Node.js 24 | ✓ expected | ✓ expected |
| Node.js 26 | ✓ expected | ✓ expected |
| Bun 1.4 | pending | pending |
Install failed in our sandbox: error: postinstall script from "node-sass" exited with 1 The rows above show what package.json declares.
How to import node-sass
ES modules (import)
import nodeSass from "node-sass";Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.
CommonJS (require)
const nodeSass = require("node-sass");Module format by version
Derived from the type, main and exports fields of every stable release on npm (132 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 3.5.3 – 9.0.0 | CommonJS | Apr 21, 2016 |
Frequently asked
Is node-sass ESM-only?
node-sass@9.0.0 is a CommonJS package. node-sass ships CommonJS only. require("node-sass") works everywhere. import "node-sass" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.
Can I import node-sass with ES module syntax?
Yes. import nodeSass from "node-sass" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.
Does node-sass ship TypeScript types?
Not bundled. Install the community types with "npm install -D @types/node-sass".
Links
Other commonjs packages
- debug 4.4.3CommonJS
- semver 7.8.5CommonJS
- ms 2.1.3CommonJS
- picomatch 4.0.7CommonJS
- ajv 8.20.0CommonJS
- source-map 0.8.0CommonJS
- react-is 19.2.8CommonJS
- readable-stream 4.7.0CommonJS
Similar popularity
- gulp-rename 2.1.0CommonJS
- metro-react-native-babel-preset 0.77.0CommonJS
- rollup-plugin-esbuild 6.2.1Dual
- babel-plugin-syntax-dynamic-import 6.18.0CommonJS
- chromedriver 152.0.3CommonJS
- request-promise 4.2.6CommonJS
- jshint 2.13.6CommonJS
- ember-cli-babel 8.3.2CommonJS