Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node-gyp issue with, cannot find module

I installed node-gyp as a global module npm install node-gyp -g When I run node-gyp, the bellow issue occurred

current node version 'v15.0.1' Os Ubuntu 20.04.3 LTS

Looking for some help.

node-gyp
node:internal/modules/cjs/loader:903
  throw err;
  ^
Error: Cannot find module 'nopt'

Require stack:
 /usr/share/nodejs/node-gyp/lib/node-gyp.js
 /usr/share/nodejs/node-gyp/bin/node-gyp.js

    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:900:15)
    at Function.Module._load (node:internal/modules/cjs/loader:745:27)
    at Module.require (node:internal/modules/cjs/loader:972:19)
    at require (node:internal/modules/cjs/helpers:88:18)
    at Object.<anonymous> (/usr/share/nodejs/node-gyp/lib/node-gyp.js:4:14)
    at Module._compile (node:internal/modules/cjs/loader:1083:30)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:10)
    at Module.load (node:internal/modules/cjs/loader:948:32)
    at Function.Module._load (node:internal/modules/cjs/loader:789:14)
    at Module.require (node:internal/modules/cjs/loader:972:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/share/nodejs/node-gyp/lib/node-gyp.js',
    '/usr/share/nodejs/node-gyp/bin/node-gyp.js'
  ]
}
like image 896
Asanka Avatar asked Jun 22 '26 05:06

Asanka


1 Answers

What helped in my case is running it with su permissions: sudo node-gyp configure

like image 193
Dmitry Statnikov Avatar answered Jun 24 '26 01:06

Dmitry Statnikov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!