npm install fibers fails with a build error on a current Node.js
npm install fibers fails while node-gyp compiles the moduleShort 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.
Fix it fast
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 fibers2Match what you see, then jump to its fix
- 1
node -v prints v16 or higher, and fibers fails to build.Node.js is 16 or newer, which fibers does not supportFix - 2
npm 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
node -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
- 1
What does the error look like?
npm install fibers fails while node-gyp compiles the modulerequire('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 -v2Fix
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.json3Verify
A clean install finishes, and npm explain finds nothing.
rm -rf node_modules package-lock.json
npm install
npm explain fibersConfirmed by raw.githubusercontent.com
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/null2Fix
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 buildConfirmed by sass-lang.com
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++ --version2Fix
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 fibers3Verify
The module loads.
node -e "require('fibers'); console.log('fibers loaded')"Confirmed by raw.githubusercontent.com
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
Back end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
corepack enable fails: permission denied while creating the pnpm link
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
corepack enable writes small link files for yarn and pnpm next to your node binary.
2 causes, each with a fixBack end
Create React App says Node is too old, and npm will not run on the new one
npm does not support Node.js v10.19.0
The shell is running an old Node.js that is below the version Create React App needs.
3 causes, each with a fixBack end
firebase deploy cannot load your functions: user code failed to load
Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
The Firebase CLI loads your functions code on your machine before it deploys, to learn which functions exist.
4 causes, each with a fixBack end
firebase deploy stops because the predeploy lint step failed
Error: There was an error deploying functions
The predeploy hook in firebase.json runs npm run lint before every deploy, and a failing hook cancels the deploy.
3 causes, each with a fixBack end
fluent-ffmpeg cannot find the ffmpeg or ffprobe binary
Error: Cannot find ffprobe
fluent-ffmpeg does not bundle ffmpeg.
4 causes, each with a fix