amilajack / node-disk-utility

Quickly calculate the size of a folder or disk on macOS and Linux
MIT License
30 stars 4 forks source link

Difficulties installing package from npm #41

Open staltz opened 3 years ago

staltz commented 3 years ago

When installing these neon npm modules, either your disk-utility or my ssb-neon-keys, both give an error upon npm install that looks like this:

➜ npm i

> disk-utility@0.0.2 install /home/staltz/oss/someproject/node_modules/disk-utility
> node-pre-gyp install --fallback-to-build=false || neon build --release

sh: 1: node-pre-gyp: not found
neon ERR! Command failed: cargo metadata --format-version=1 --no-deps
error: could not find `Cargo.toml` in `/home/staltz/oss/someproject/node_modules/disk-utility/native` or any parent directory

or

➜  npm i

> ssb-neon-keys@7.2.0-2 postinstall /home/staltz/oss/someproject/node_modules/ssb-neon-keys
> node-pre-gyp install --fallback-to-build=false || neon build --release

sh: 1: node-pre-gyp: not found
neon ERR! spawn cargo ENOENT

Error: spawn cargo ENOENT

This seems to be the case regardless if node-pre-gyp is defined in package.json > scripts > install or package.json > scripts > postinstall. I'm wondering if you stumbled upon this error before, and how did you resolve it?

More info on my local setup:

➜ npm version
{ someproject: '1.0.0',
  npm: '6.4.1',
  ares: '1.15.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.15.3',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '6.8.275.32-node.51',
  zlib: '1.2.11' }
➜ uname -a
Linux computername 4.15.0-117-generic #118-Ubuntu SMP Fri Sep 4 20:02:41 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
➜ cargo -V
cargo 1.40.0 (bc8e4c8be 2019-11-22)
muuvmuuv commented 3 years ago

After installing node-pre-gyp I get this:

Error: The module '/node_modules/disk-utility/native/index.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 83. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

I installed the lib with node 14 lts release.

amilajack commented 3 years ago

@staltz I'm not able to reproduce that error

amilajack commented 3 years ago

@muuvmuuv interesting. Interesting. What's the entire stacktrace?

amilajack commented 3 years ago

@staltz to clarify, are you running into that when installing npm modules for the locally cloned project or are you getting that error when running npm install on a project that consumes disk-utility?

muuvmuuv commented 3 years ago

@amilajack

Last login: Fri Jan 15 09:28:26 on ttys006

~/Downloads took 833ms at 09:38:28
❯ mkdir test

~/Downloads at 09:38:43
❯ cd test

~/Downloads/test at 09:38:44
❯ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (test)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to /Users/marvinheilemann/Downloads/test/package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Is this OK? (yes)

~/Downloads/test is 📦 v1.0.0 via ⬢ v14.15.4 took 4s592ms at 09:38:51
❯ npm i disk-utility

> disk-utility@0.0.2 install /Users/marvinheilemann/Downloads/test/node_modules/disk-utility
> node-pre-gyp install --fallback-to-build=false || neon build --release

node-pre-gyp WARN Using needle for node-pre-gyp https download
[disk-utility] Success: "/Users/marvinheilemann/Downloads/test/node_modules/disk-utility/native/index.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN test@1.0.0 No description
npm WARN test@1.0.0 No repository field.

+ disk-utility@0.0.2
added 165 packages from 115 contributors and audited 165 packages in 11.656s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

~/Downloads/test is 📦 v1.0.0 via ⬢ v14.15.4 took 12s331ms at 09:39:17
❯ vim test.js

~/Downloads/test is 📦 v1.0.0 via ⬢ v14.15.4 took 57s497ms at 09:40:24
❯ cat test.js
const disk = require("disk-utility")

const size = disk.dirSize(__dirname)

console.log(size)

~/Downloads/test is 📦 v1.0.0 via ⬢ v14.15.4 at 09:40:28
❯ node test.js
internal/modules/cjs/loader.js:1122
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The module '/Users/marvinheilemann/Downloads/test/node_modules/disk-utility/native/index.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 83. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1122:18)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/marvinheilemann/Downloads/test/node_modules/disk-utility/lib/index.js:1:18)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
muuvmuuv commented 3 years ago

Rebuilding prints this error:

~/Downloads/test is 📦 v1.0.0 via ⬢ v14.15.4 at 09:45:33
❯ npm rebuild --build-from-source --update-binary

> disk-utility@0.0.2 install /Users/marvinheilemann/Downloads/test/node_modules/disk-utility
> node-pre-gyp install --fallback-to-build=false || neon build --release

node-pre-gyp WARN Using needle for node-pre-gyp https download
gyp: binding.gyp not found (cwd: /Users/marvinheilemann/Downloads/test/node_modules/disk-utility) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/marvinheilemann/.volta/tools/image/node/14.15.4/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/Users/marvinheilemann/.volta/tools/image/node/14.15.4/bin/node" "/Users/marvinheilemann/.volta/tools/image/node/14.15.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build=false" "--module=/Users/marvinheilemann/Downloads/test/node_modules/disk-utility/native/index.node" "--module_name=index" "--module_path=/Users/marvinheilemann/Downloads/test/node_modules/disk-utility/native" "--napi_version=7" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v83"
gyp ERR! cwd /Users/marvinheilemann/Downloads/test/node_modules/disk-utility
gyp ERR! node -v v14.15.4
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/Users/marvinheilemann/.volta/tools/image/node/14.15.4/bin/node /Users/marvinheilemann/.volta/tools/image/node/14.15.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build=false --module=/Users/marvinheilemann/Downloads/test/node_modules/disk-utility/native/index.node --module_name=index --module_path=/Users/marvinheilemann/Downloads/test/node_modules/disk-utility/native --napi_version=7 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/marvinheilemann/.volta/tools/image/packages/node-pre-gyp/lib/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1048:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
node-pre-gyp ERR! System Darwin 19.6.0
node-pre-gyp ERR! command "/Users/marvinheilemann/.volta/tools/image/node/14.15.4/bin/node" "/Users/marvinheilemann/.volta/tools/image/packages/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build=false"
node-pre-gyp ERR! cwd /Users/marvinheilemann/Downloads/test/node_modules/disk-utility
node-pre-gyp ERR! node -v v14.15.4
node-pre-gyp ERR! node-pre-gyp -v v0.17.0
node-pre-gyp ERR! not ok
Failed to execute '/Users/marvinheilemann/.volta/tools/image/node/14.15.4/bin/node /Users/marvinheilemann/.volta/tools/image/node/14.15.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build=false --module=/Users/marvinheilemann/Downloads/test/node_modules/disk-utility/native/index.node --module_name=index --module_path=/Users/marvinheilemann/Downloads/test/node_modules/disk-utility/native --napi_version=7 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
neon ERR! Command failed: cargo metadata --format-version=1 --no-deps
error: could not find `Cargo.toml` in `/Users/marvinheilemann/Downloads/test/node_modules/disk-utility/native` or any parent directory

Error: Command failed: cargo metadata --format-version=1 --no-deps
error: could not find `Cargo.toml` in `/Users/marvinheilemann/Downloads/test/node_modules/disk-utility/native` or any parent directory

    at ChildProcess.exithandler (child_process.js:308:12)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1048:16)
    at Socket.<anonymous> (internal/child_process.js:439:11)
    at Socket.emit (events.js:315:20)
    at Pipe.<anonymous> (net.js:673:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! disk-utility@0.0.2 install: `node-pre-gyp install --fallback-to-build=false || neon build --release`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the disk-utility@0.0.2 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!     /Users/marvinheilemann/.npm/_logs/2021-01-19T08_46_37_139Z-debug.log