Node.js 10执行sudo npm install时fibers@1.0.15安装报错求助
Let's tackle this issue head-on—you're hitting a permission error when installing fibers with sudo npm install, even though your app runs fine locally. Here's what's going wrong and how to fix it:
First, let's recap your error (for reference):
fibers@1.0.15 install /home/tickets/www/tickets_parser/node_modules/fibers node build.js || nodejs build.js gyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/tickets/www/tickets_parser/node_modules/fibers/build' gyp ERR! System Linux 4.4.0-97-generic gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release" gyp ERR! cwd /home/tickets/www/tickets_parser/node_modules/fibers gyp ERR! node -v v10.0.0 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok node-gyp exited with code: 1 Please make sure you are using a supported platform and node version. If you would like to compile fibers on this machine please make sure you have setup your build environment-- Windows + OS X instructions here: https://github.com/nodejs/node-gyp Ubuntu users please run: sudo apt-get install g++ build-essential Alpine users please run: sudo apk add python make g++ gyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/tickets/www/tickets_parser/node_modules/fibers/build' gyp ERR! System Linux 4.4.0-97-generic gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release" gyp ERR! cwd /home/tickets/www/tickets_parser/node_modules/fibers gyp ERR! node -v v10.0.0 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok node-gyp exited with code: 1 Please make sure you are using a supported platform and node version. If you would like to compile fibers on this machine please make sure you have setup your build environment-- Windows + OS X instructions here: https://github.com/nodejs/node-gyp Ubuntu users please run: sudo apt-get install g++ build-essential Alpine users please run: sudo apk add python make g++ npm WARN tickets_parser@0.0.0 No description npm WARN tickets_parser@0.0.0 No repository field. npm WARN tickets_parser@0.0.0 No license field. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! fibers@1.0.15 install: node build.js || nodejs build.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the fibers@1.0.15 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /home/tickets/.npm/_logs/2018-05-14T19_08_18_241Z-debug.log
Step 1: Install Required Build Dependencies
The error explicitly calls out missing build tools. First, install them on your Ubuntu system:
sudo apt-get update && sudo apt-get install g++ build-essential python
Step 2: Fix npm Permissions (Stop Using sudo for Installs)
Using sudo to install npm packages often creates files owned by root, leading to permission conflicts later. Let's fix this:
- Reset ownership of your project's
node_modulesdirectory back to your user:sudo chown -R $USER:$USER /home/tickets/www/tickets_parser/node_modules - Configure npm to use a local directory for global packages (so you never need
sudoagain):mkdir -p ~/.npm-global npm config set prefix '~/.npm-global' echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile source ~/.profile
Step 3: Update fibers to a Node.js 10 Compatible Version
fibers@1.0.15 is outdated and doesn't fully support Node.js 10. Upgrade to a version that works:
- Uninstall the old fibers package:
npm uninstall fibers - Install a Node.js 10-compatible version (v3.1.1 is a reliable choice):
npm install fibers@^3.1.1
Step 4: Clean Cache and Reinstall (If Issues Persist)
If you're still seeing errors, clear npm's cache and start fresh:
npm cache clean --force rm -rf node_modules package-lock.json npm install
These steps should resolve the permission error and get fibers installed correctly on your Node.js 10 environment.
内容的提问来源于stack exchange,提问作者Michael Fedorov

