node.jsnpmnpm-installnode-gyp

Can't run any NPM 9.6.4 command at all. They all run into `gyp error`


$ n doctor
Check                               Value   Recommendation/Notes
npm ping                            ok       
npm -v                              ok      current: v9.6.4, latest: v9.6.4
node -v                             ok      current: v19.8.1, recommended: v19.8.1
npm config get registry             ok      using default registry (https://registry.npmjs.org/)
git executable in PATH              ok      /usr/bin/git
global bin folder in PATH           ok      /usr/local/bin
Perms check on cached files         ok       
Perms check on local node_modules   ok       
Perms check on global node_modules  ok       
Perms check on local bin folder     ok       
Perms check on global bin folder    ok       
npm WARN verifyCachedFiles Content garbage-collected: 162 (72726571 bytes)
npm WARN verifyCachedFiles Cache issues have been fixed
Verify cache contents               ok      verified 15972 tarballs
$ n i
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'core@1.0.113',
npm WARN EBADENGINE   required: { node: '0.6 || 0.8' },
npm WARN EBADENGINE   current: { node: 'v19.8.1', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'core@1.0.113',
npm WARN EBADENGINE   required: { node: '0.6 || 0.8' },
npm WARN EBADENGINE   current: { node: 'v19.8.1', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated formidable@1.2.6: Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated superagent@3.8.3: Please upgrade to v7.0.2+ of superagent.  We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing.  See the releases tab for more information at <https://github.com/visionmedia/superagent/releases>.
npm ERR! code 1
npm ERR! path /usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer/build'
npm ERR!   CXX(target) Release/obj.target/compress_buffer_bindings/src/compress-buffer.o
npm ERR! make: Leaving directory '/usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.3.1
npm ERR! gyp info using node@19.8.1 | linux | x64
npm ERR! gyp info find Python using Python version 3.10.7 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   '/usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer/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   '/home/khteh/.cache/node-gyp/19.8.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=/home/khteh/.cache/node-gyp/19.8.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=/home/khteh/.cache/node-gyp/19.8.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer',
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 info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! ../src/compress-buffer.cc:23:1: error: ‘Handle’ does not name a type
npm ERR!    23 | Handle<Value> ThrowNodeError(const char* what = NULL) {
npm ERR!       | ^~~~~~
npm ERR! ../src/compress-buffer.cc:27:1: error: ‘Handle’ does not name a type
npm ERR!    27 | Handle<Value> compress(const Arguments& args) {
npm ERR!       | ^~~~~~
npm ERR! ../src/compress-buffer.cc:97:1: error: ‘Handle’ does not name a type
npm ERR!    97 | Handle<Value> uncompress(const Arguments &args) {
npm ERR!       | ^~~~~~
npm ERR! ../src/compress-buffer.cc:183:1: error: variable or field ‘init’ declared void
npm ERR!   183 | init (Handle<Object> target) {
npm ERR!       | ^~~~
npm ERR! ../src/compress-buffer.cc:183:7: error: ‘Handle’ was not declared in this scope
npm ERR!   183 | init (Handle<Object> target) {
npm ERR!       |       ^~~~~~
npm ERR! ../src/compress-buffer.cc:183:20: error: expected primary-expression before ‘>’ token
npm ERR!   183 | init (Handle<Object> target) {
npm ERR!       |                    ^
npm ERR! ../src/compress-buffer.cc:183:22: error: ‘target’ was not declared in this scope
npm ERR!   183 | init (Handle<Object> target) {
npm ERR!       |                      ^~~~~~
npm ERR! In file included from ../src/compress-buffer.cc:1:
npm ERR! ../src/compress-buffer.cc:200:39: error: ‘init’ was not declared in this scope; did you mean ‘int’?
npm ERR!   200 | NODE_MODULE(compress_buffer_bindings, init);
npm ERR!       |                                       ^~~~
npm ERR! /home/khteh/.cache/node-gyp/19.8.1/include/node/node.h:1168:36: note: in definition of macro ‘NODE_MODULE_X’
npm ERR!  1168 |       (node::addon_register_func) (regfunc),                          \
npm ERR!       |                                    ^~~~~~~
npm ERR! ../src/compress-buffer.cc:200:1: note: in expansion of macro ‘NODE_MODULE’
npm ERR!   200 | NODE_MODULE(compress_buffer_bindings, init);
npm ERR!       | ^~~~~~~~~~~
npm ERR! make: *** [compress_buffer_bindings.target.mk:111: Release/obj.target/compress_buffer_bindings/src/compress-buffer.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:512:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm ERR! gyp ERR! System Linux 5.19.0-35-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 /usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer
npm ERR! gyp ERR! node -v v19.8.1
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/khteh/.npm/_logs/2023-03-17T06_25_22_733Z-debug-0.log
$ node -v
v19.8.1
$ npm -v
9.6.4

Update / upgrade runs into the same errors:

$ n outdated
Package          Current  Wanted  Latest  Location  Depended by
@types/morgan    MISSING   1.9.4   1.9.4  -         Node.JSRestAPI
ansi-regex       MISSING   6.0.1   6.0.1  -         Node.JSRestAPI
async            MISSING   3.2.4   3.2.4  -         Node.JSRestAPI
compression      MISSING   1.7.4   1.7.4  -         Node.JSRestAPI
config           MISSING   3.3.9   3.3.9  -         Node.JSRestAPI
cookie-parser    MISSING   1.4.6   1.4.6  -         Node.JSRestAPI
cors             MISSING   2.8.5   2.8.5  -         Node.JSRestAPI
debug            MISSING   4.3.4   4.3.4  -         Node.JSRestAPI
ejs              MISSING   3.1.9   3.1.9  -         Node.JSRestAPI
email-validator  MISSING   2.0.4   2.0.4  -         Node.JSRestAPI
express          MISSING  4.18.2  4.18.2  -         Node.JSRestAPI
helmet           MISSING   6.0.1   6.0.1  -         Node.JSRestAPI
http-errors      MISSING   2.0.0   2.0.0  -         Node.JSRestAPI
morgan           MISSING  1.10.0  1.10.0  -         Node.JSRestAPI
morgan-json      MISSING   1.1.0   1.1.0  -         Node.JSRestAPI
pg               MISSING  8.10.0  8.10.0  -         Node.JSRestAPI
spdy             MISSING   4.0.2   4.0.2  -         Node.JSRestAPI
$ n update -S
npm WARN ERESOLVE overriding peer dependency
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'core@1.0.113',
npm WARN EBADENGINE   required: { node: '0.6 || 0.8' },
npm WARN EBADENGINE   current: { node: 'v19.8.1', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'core@1.0.113',
npm WARN EBADENGINE   required: { node: '0.6 || 0.8' },
npm WARN EBADENGINE   current: { node: 'v19.8.1', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated formidable@1.2.6: Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated superagent@3.8.3: Please upgrade to v7.0.2+ of superagent.  We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing.  See the releases tab for more information at <https://github.com/visionmedia/superagent/releases>.
npm ERR! code 1
npm ERR! path /usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer/build'
npm ERR!   CXX(target) Release/obj.target/compress_buffer_bindings/src/compress-buffer.o
npm ERR! make: Leaving directory '/usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.3.1
npm ERR! gyp info using node@19.8.1 | linux | x64
npm ERR! gyp info find Python using Python version 3.10.7 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   '/usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer/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   '/home/khteh/.cache/node-gyp/19.8.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=/home/khteh/.cache/node-gyp/19.8.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=/home/khteh/.cache/node-gyp/19.8.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer',
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 info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! ../src/compress-buffer.cc:23:1: error: ‘Handle’ does not name a type
npm ERR!    23 | Handle<Value> ThrowNodeError(const char* what = NULL) {
npm ERR!       | ^~~~~~
npm ERR! ../src/compress-buffer.cc:27:1: error: ‘Handle’ does not name a type
npm ERR!    27 | Handle<Value> compress(const Arguments& args) {
npm ERR!       | ^~~~~~
npm ERR! ../src/compress-buffer.cc:97:1: error: ‘Handle’ does not name a type
npm ERR!    97 | Handle<Value> uncompress(const Arguments &args) {
npm ERR!       | ^~~~~~
npm ERR! ../src/compress-buffer.cc:183:1: error: variable or field ‘init’ declared void
npm ERR!   183 | init (Handle<Object> target) {
npm ERR!       | ^~~~
npm ERR! ../src/compress-buffer.cc:183:7: error: ‘Handle’ was not declared in this scope
npm ERR!   183 | init (Handle<Object> target) {
npm ERR!       |       ^~~~~~
npm ERR! ../src/compress-buffer.cc:183:20: error: expected primary-expression before ‘>’ token
npm ERR!   183 | init (Handle<Object> target) {
npm ERR!       |                    ^
npm ERR! ../src/compress-buffer.cc:183:22: error: ‘target’ was not declared in this scope
npm ERR!   183 | init (Handle<Object> target) {
npm ERR!       |                      ^~~~~~
npm ERR! In file included from ../src/compress-buffer.cc:1:
npm ERR! ../src/compress-buffer.cc:200:39: error: ‘init’ was not declared in this scope; did you mean ‘int’?
npm ERR!   200 | NODE_MODULE(compress_buffer_bindings, init);
npm ERR!       |                                       ^~~~
npm ERR! /home/khteh/.cache/node-gyp/19.8.1/include/node/node.h:1168:36: note: in definition of macro ‘NODE_MODULE_X’
npm ERR!  1168 |       (node::addon_register_func) (regfunc),                          \
npm ERR!       |                                    ^~~~~~~
npm ERR! ../src/compress-buffer.cc:200:1: note: in expansion of macro ‘NODE_MODULE’
npm ERR!   200 | NODE_MODULE(compress_buffer_bindings, init);
npm ERR!       | ^~~~~~~~~~~
npm ERR! make: *** [compress_buffer_bindings.target.mk:111: Release/obj.target/compress_buffer_bindings/src/compress-buffer.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:512:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm ERR! gyp ERR! System Linux 5.19.0-35-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 /usr/src/Node.JSRestAPI/src/infrastructure/node_modules/core/node_modules/compress-buffer
npm ERR! gyp ERR! node -v v19.8.1
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/khteh/.npm/_logs/2023-03-17T07_11_28_800Z-debug-0.log
$ n ls core
node.jsrestapi@1.0.0 /usr/src/Node.JSRestAPI
└── (empty)

Solution

  • I've run into similar issues resolved by the following:

    What seems strange to me is the core@1.0.113 requirement, which is not a dependency of anything show from you npm oudated output. That's where the compress_buffer dependency is coming from. Is there anything else installed globally that can be causing issues - npm outdated -g?