Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

npm install fibers fails with a build error on a current Node.js

Errornpm install fibers fails while node-gyp compiles the module

Short answer

The fibers package does not work on Node.js 16 or later, and its author has said so. No flag or toolchain fixes that. Find out what pulls fibers into the project, remove it, and use async code or a tool version that does not need it. Only on Node.js 12 or 14 does a build toolchain matter.

  • Applies to Node.js 22, Node.js 24, npm 10, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check your Node.js version, then ask npm which dependency chain brings fibers in. The two answers point to the cause.

    node -v
    npm explain fibers
  2. 2Match what you see, then jump to its fix

    1. 1node -v prints v16 or higher, and fibers fails to build.Node.js is 16 or newer, which fibers does not supportFix
    2. 2npm explain fibers shows a path through a Sass tool, or your config sets fibers next to the Sass options.Sass build settings still pass a fibers optionFix
    3. 3node -v prints v12 or v14, and node-gyp stops because no compiler is found.You are pinned to Node.js 12 or 14 and the build toolchain is missingFix

What does the error look like?

  • npm install fibers fails while node-gyp compiles the module
  • require('fibers') cannot find the compiled fibers.node

Cause 1 of 3

Node.js is 16 or newer, which fibers does not support

1Check

The fibers README states that Fibers is not compatible with Node.js v16.0.0 or later. Its listed platforms are 64-bit Node.js 12.x and 14.x. A compiler, node-gyp or Python cannot change this.

node -v

2Fix

Do not install fibers. Remove it from package.json and rewrite the code that used it with async and await, or with the maintained replacement that the tool you use names.

npm uninstall fibers
grep -rn "fibers" src/ package.json

3Verify

A clean install finishes, and npm explain finds nothing.

rm -rf node_modules package-lock.json
npm install
npm explain fibers

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 3

Sass build settings still pass a fibers option

1Check

Dart Sass used fibers to speed up its asynchronous render() calls. The Sass team announced that it would not work on Node.js 16 and later, so passing it is no longer an option.

grep -rn "fibers" webpack.config.js vue.config.js gulpfile.js package.json 2>/dev/null

2Fix

Delete the fibers value from the Sass options. The current Dart Sass API, compile(), is synchronous and needs no fibers. The older render() and renderSync() are deprecated and stay supported only until version 2.0.0 of the sass package.

// before (legacy API)
sass.render({ file: 'app.scss', fibers: Fiber }, callback);

// after
const result = sass.compile('app.scss');
console.log(result.css);

3Verify

Run the style build again.

npm run build

Confirmed by sass-lang.com

Did this fix it?

Cause 3 of 3

You are pinned to Node.js 12 or 14 and the build toolchain is missing

1Check

On a supported version, fibers compiles with node-gyp. The README asks you to install node-gyp globally and set up the build environment it describes. Ubuntu-based systems may also need g++.

g++ --version

2Fix

Install the compiler and node-gyp, then install fibers again. Treat this as a stop-gap: plan the move to code that does not need fibers.

sudo apt install g++
npm install -g node-gyp
npm install fibers

3Verify

The module loads.

node -e "require('fibers'); console.log('fibers loaded')"

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Do not add fibers to a new project. Write asynchronous code with async and await.
  • Pin the Node.js version in package.json (engines) and in CI, so an old dependency fails in review and not in production.
  • Run npm explain on any package that breaks an install, to see who depends on it before you touch the lockfile.
  • Update build tools together with Node.js, and read their release notes for removed options.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.