Cannot install plugins with NPM, works with yarn

Hey there forums,

CONTEXT:

This is my first time posting in netlify. I have a colleague who has build a nextjs app inside of netlify and it has been deployed and everything works fine on her machine. She is using a macbook, I am using ubuntu on a lenovo thinkpad x1 carbon extreme gen 3.

PROBLEM:

I can’t get the command “sudo netlify dev” or “sudo netlify build” to work on machine using npm install, but I can get it to work if I use yarn. I’ve narrowed down the problem to the installation of plugins. I can get everything to install correctly, but when I get to the installation of the plugins I get the following error:

sudo netlify build

Netlify Build                                                 
────────────────────────────────────────────────────────────────

❯ Version
  @netlify/build 29.33.7

❯ Flags
  dry: false
  offline: false

❯ Current directory
  /home/crunchy/Documents/GitHub/goodchange-app

❯ Config file
  /home/crunchy/Documents/GitHub/goodchange-app/netlify.toml

❯ Context
  production

❯ Installing plugins
   - @netlify/plugin-nextjs@4.41.3
   - @netlify/plugin-lighthouse@6.0.0

Dependencies installation error                               
────────────────────────────────────────────────────────────────

  Error message
  Error while installing dependencies in /home/crunchy/Documents/GitHub/goodchange-app/.netlify/plugins/
  npm WARN deprecated intl-messageformat-parser@1.8.1: We've written a new parser that's 6x faster and is backwards compatible. Please use @formatjs/icu-messageformat-parser
  npm WARN deprecated puppeteer@18.2.1: < 21.5.0 is no longer supported
  npm ERR! code 1
  npm ERR! path /home/crunchy/Documents/GitHub/goodchange-app/.netlify/plugins/node_modules/@parcel/watcher
  npm ERR! command failed
  npm ERR! command sh -c node-gyp rebuild
  npm ERR! gyp info it worked if it ends with ok
  npm ERR! gyp info using node-gyp@10.0.1
  npm ERR! gyp info using node@20.5.1 | linux | x64
  npm ERR! gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
  npm ERR! gyp info spawn /usr/bin/python3
  npm ERR! gyp info spawn args [
  npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
  npm ERR! gyp info spawn args 'binding.gyp',
  npm ERR! gyp info spawn args '-f',
  npm ERR! gyp info spawn args 'make',
  npm ERR! gyp info spawn args '-I',
  npm ERR! gyp info spawn args '/home/crunchy/Documents/GitHub/goodchange-app/.netlify/plugins/node_modules/@parcel/watcher/build/config.gypi',
  npm ERR! gyp info spawn args '-I',
  npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
  npm ERR! gyp info spawn args '-I',
  npm ERR! gyp info spawn args '/root/.cache/node-gyp/20.5.1/include/node/common.gypi',
  npm ERR! gyp info spawn args '-Dlibrary=shared_library',
  npm ERR! gyp info spawn args '-Dvisibility=default',
  npm ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/20.5.1',
  npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
  npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/20.5.1/<(target_arch)/node.lib',
  npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/crunchy/Documents/GitHub/goodchange-app/.netlify/plugins/node_modules/@parcel/watcher',
  npm ERR! gyp info spawn args '-Dnode_engine=v8',
  npm ERR! gyp info spawn args '--depth=.',
  npm ERR! gyp info spawn args '--no-parallel',
  npm ERR! gyp info spawn args '--generator-output',
  npm ERR! gyp info spawn args 'build',
  npm ERR! gyp info spawn args '-Goutput_dir=.'
  npm ERR! gyp info spawn args ]
  npm ERR! gyp: binding.gyp not found (cwd: /home/crunchy/Documents/GitHub/goodchange-app/.netlify/plugins/node_modules/@parcel/watcher) while trying to load binding.gyp
  npm ERR! gyp ERR! configure error 
  npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
  npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:271:18)
  npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:514:28)
  npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
  npm ERR! gyp ERR! System Linux 6.5.0-18-generic
  npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
  npm ERR! gyp ERR! cwd /home/crunchy/Documents/GitHub/goodchange-app/.netlify/plugins/node_modules/@parcel/watcher
  npm ERR! gyp ERR! node -v v20.5.1
  npm ERR! gyp ERR! node-gyp -v v10.0.1
  npm ERR! gyp ERR! not ok
​
  Resolved config
  build:
    command: npm run build
    commandOrigin: ui
    publish: /home/crunchy/Documents/GitHub/goodchange-app/.next
    publishOrigin: ui
  functions:
    '*':
      node_bundler: esbuild
  functionsDirectory: /home/crunchy/Documents/GitHub/goodchange-app/netlify/functions
  plugins:
    - inputs: {}
      origin: ui
      package: '@netlify/plugin-nextjs'
    - inputs: {}
      origin: ui
      package: '@netlify/plugin-lighthouse'
  redirects:
    - from: /lakeslia4arkansas
      to: https://www.goodchange.app/donate/lakeslia4arkansas?discovered=true
  redirectsOrigin: config

   ╭─────────────────────────────────────────╮
   │                                         │
   │   Update available 17.16.2 → 17.16.4    │
   │   Run npm i -g netlify-cli to update    │
   │                                         │
   ╰─────────────────────────────────────────╯

If I try to install the plugins individually using npm install, the command fails with the same error. As the title states, if I try to install the plugins using yarn then it doesn’t fail and I can proceed as normal. I can’t go that route in the long term though because I am bringing on more colleagues on this project and they all need to be using npm and not yarn. Does anyone have any insight on this?

Thank you so much!


Netlify site name: secure-donations
Local Machine:

Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy

Node version: v18.19.1
Node version enabled in app is 18.x

You might wish to try the suggestion in this Stack Overflow post

I am about to test this in a VM.

Update: Worked for me.

You think this a permissions issue?

You shouldn’t (and shouldn’t need to) run standard commands such as those for npm modules as the root user. Might as well run sudo rm -rf /* (seriously, don’t!)

I’ll take your word for it, I’m sort of new to linux. Okay, I guess I’ll look into this direction. I hope it works out

1 Like