使用 npm 安装 firebase 时 gyp 和 node-pre-gyp 失败
gyp and node-pre-gyp fail when installing firebase with npm
我正在尝试使用 npm 安装我的依赖项,但是当安装 firebase 时安装失败。我尝试使用 npm i firebase
单独安装 firebase 但它不起作用。我删除了 node_modules 文件夹,清理了缓存并再次安装,但它也不起作用。
npm 显示的第一个错误是下载 grpc-precompiled-binaries 时的 403 错误代码。我认为这是主要问题,它取决于下一个错误,但我不确定。有人可以告诉我如何使用 npm 成功安装 firebase 吗?
输出:
node-pre-gyp ERR! Tried to download(403): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.7.2/node-v57-linux-x64-musl.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for grpc@1.7.2 and node@8.5.0 (node-v57 ABI, musl) (falling back to source compile with node-gyp)
node-pre-gyp http 403 status code downloading tarball https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.7.2/node-v57-linux-x64-musl.tar.gz
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@8.5.0 | linux | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@8.5.0 | linux | x64
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (/app/node_modules/node-gyp/lib/configure.js:483:19)
gyp ERR! stack at PythonFinder.<anonymous> (/app/node_modules/node-gyp/lib/configure.js:397:16)
gyp ERR! stack at F (/app/node_modules/which/which.js:68:16)
gyp ERR! stack at E (/app/node_modules/which/which.js:80:29)
gyp ERR! stack at /app/node_modules/which/which.js:89:16
gyp ERR! stack at /app/node_modules/isexe/index.js:42:5
gyp ERR! stack at /app/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:153:21)
gyp ERR! System Linux 4.4.0-101-generic
gyp ERR! command "/usr/local/bin/node" "/app/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl/grpc_node.node" "--module_name=grpc_node" "--module_path=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl"
gyp ERR! cwd /app/node_modules/grpc
gyp ERR! node -v v8.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /app/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl/grpc_node.node --module_name=grpc_node --module_path=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/app/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:125:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:213:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:927:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 4.4.0-101-generic
node-pre-gyp ERR! command "/usr/local/bin/node" "/app/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /app/node_modules/grpc
node-pre-gyp ERR! node -v v8.5.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /app/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl/grpc_node.node --module_name=grpc_node --module_path=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl' (1)
npm info lifecycle grpc@1.7.2~install: Failed to exec install script
npm WARN codelyzer@3.2.2 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
npm WARN codelyzer@3.2.2 requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@1.7.2 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc@1.7.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
日志文件的最后一部分
3366 info lifecycle protobufjs@5.0.2~install: protobufjs@5.0.2
3367 silly install grpc@1.7.2
3368 info lifecycle grpc@1.7.2~install: grpc@1.7.2
3369 verbose lifecycle grpc@1.7.2~install: unsafe-perm in lifecycle false
3370 verbose lifecycle grpc@1.7.2~install: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/app/node_modules/grpc/node_modules/.bin:/app/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
3371 verbose lifecycle grpc@1.7.2~install: CWD: /app/node_modules/grpc
3372 silly lifecycle grpc@1.7.2~install: Args: [ '-c',
3372 silly lifecycle 'node-pre-gyp install --fallback-to-build --library=static_library' ]
3373 silly lifecycle grpc@1.7.2~install: Returned: code: 1 signal: null
3374 info lifecycle grpc@1.7.2~install: Failed to exec install script
3375 verbose unlock done using /root/.npm/_locks/staging-bd3355550c5a469e.lock for /app/node_modules/.staging
3376 warn codelyzer@3.2.2 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
3377 warn codelyzer@3.2.2 requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
3378 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
3379 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
3380 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
3380 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
3380 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: linux
3380 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
3381 verbose stack Error: grpc@1.7.2 install: `node-pre-gyp install --fallback-to-build --library=static_library`
3381 verbose stack Exit status 1
3381 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
3381 verbose stack at emitTwo (events.js:125:13)
3381 verbose stack at EventEmitter.emit (events.js:213:7)
3381 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
3381 verbose stack at emitTwo (events.js:125:13)
3381 verbose stack at ChildProcess.emit (events.js:213:7)
3381 verbose stack at maybeClose (internal/child_process.js:927:16)
3381 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
3382 verbose pkgid grpc@1.7.2
3383 verbose cwd /app
3384 verbose Linux 4.4.0-101-generic
3385 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "firebase"
3386 verbose node v8.5.0
3387 verbose npm v5.3.0
3388 error code ELIFECYCLE
3389 error errno 1
3390 error grpc@1.7.2 install: `node-pre-gyp install --fallback-to-build --library=static_library`
3390 error Exit status 1
3391 error Failed at the grpc@1.7.2 install script.
3391 error This is probably not a problem with npm. There is likely additional logging output above.
3392 verbose exit [ 1, true ]
环境:
OS: Ubuntu 16.04
npm: 5.3.0
节点:8.5.0
更新:
这个答案让我能够启动我的应用程序并 运行 在我的 alpine 容器中。在您的开发环境中尝试 运行 此代码。希望这有帮助。
Ran into the same issue this morning. Looks like the precompiled grpc1.7.2 hasn't been uploaded for musl based distributions (alpine is musl vs glibc)
For the short term, to get your build going again, and until they upload the precompiled versions, try adding this to your dockerfile
apk update && apk upgrade &&
apk add --no-cache python make g++
python, make and g++ basically allow node-gyp to compile from source rather than >relying on the precompiled versions
我在创建 docker 图像时遇到了同样的问题 运行。我注意到在使用 Linux-alpine 节点基础图像时,出现了这个错误。然而,
使用标准节点(我认为 Ubuntu 14.04)基本图像时它工作正常。 OS 你在用什么?希望你能找到解决办法!
我正在尝试使用 npm 安装我的依赖项,但是当安装 firebase 时安装失败。我尝试使用 npm i firebase
单独安装 firebase 但它不起作用。我删除了 node_modules 文件夹,清理了缓存并再次安装,但它也不起作用。
npm 显示的第一个错误是下载 grpc-precompiled-binaries 时的 403 错误代码。我认为这是主要问题,它取决于下一个错误,但我不确定。有人可以告诉我如何使用 npm 成功安装 firebase 吗?
输出:
node-pre-gyp ERR! Tried to download(403): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.7.2/node-v57-linux-x64-musl.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for grpc@1.7.2 and node@8.5.0 (node-v57 ABI, musl) (falling back to source compile with node-gyp)
node-pre-gyp http 403 status code downloading tarball https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.7.2/node-v57-linux-x64-musl.tar.gz
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@8.5.0 | linux | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@8.5.0 | linux | x64
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (/app/node_modules/node-gyp/lib/configure.js:483:19)
gyp ERR! stack at PythonFinder.<anonymous> (/app/node_modules/node-gyp/lib/configure.js:397:16)
gyp ERR! stack at F (/app/node_modules/which/which.js:68:16)
gyp ERR! stack at E (/app/node_modules/which/which.js:80:29)
gyp ERR! stack at /app/node_modules/which/which.js:89:16
gyp ERR! stack at /app/node_modules/isexe/index.js:42:5
gyp ERR! stack at /app/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:153:21)
gyp ERR! System Linux 4.4.0-101-generic
gyp ERR! command "/usr/local/bin/node" "/app/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl/grpc_node.node" "--module_name=grpc_node" "--module_path=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl"
gyp ERR! cwd /app/node_modules/grpc
gyp ERR! node -v v8.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /app/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl/grpc_node.node --module_name=grpc_node --module_path=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/app/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:125:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:213:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:927:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 4.4.0-101-generic
node-pre-gyp ERR! command "/usr/local/bin/node" "/app/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /app/node_modules/grpc
node-pre-gyp ERR! node -v v8.5.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /app/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl/grpc_node.node --module_name=grpc_node --module_path=/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-musl' (1)
npm info lifecycle grpc@1.7.2~install: Failed to exec install script
npm WARN codelyzer@3.2.2 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
npm WARN codelyzer@3.2.2 requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@1.7.2 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc@1.7.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
日志文件的最后一部分
3366 info lifecycle protobufjs@5.0.2~install: protobufjs@5.0.2
3367 silly install grpc@1.7.2
3368 info lifecycle grpc@1.7.2~install: grpc@1.7.2
3369 verbose lifecycle grpc@1.7.2~install: unsafe-perm in lifecycle false
3370 verbose lifecycle grpc@1.7.2~install: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/app/node_modules/grpc/node_modules/.bin:/app/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
3371 verbose lifecycle grpc@1.7.2~install: CWD: /app/node_modules/grpc
3372 silly lifecycle grpc@1.7.2~install: Args: [ '-c',
3372 silly lifecycle 'node-pre-gyp install --fallback-to-build --library=static_library' ]
3373 silly lifecycle grpc@1.7.2~install: Returned: code: 1 signal: null
3374 info lifecycle grpc@1.7.2~install: Failed to exec install script
3375 verbose unlock done using /root/.npm/_locks/staging-bd3355550c5a469e.lock for /app/node_modules/.staging
3376 warn codelyzer@3.2.2 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
3377 warn codelyzer@3.2.2 requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
3378 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
3379 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
3380 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
3380 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
3380 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: linux
3380 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
3381 verbose stack Error: grpc@1.7.2 install: `node-pre-gyp install --fallback-to-build --library=static_library`
3381 verbose stack Exit status 1
3381 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
3381 verbose stack at emitTwo (events.js:125:13)
3381 verbose stack at EventEmitter.emit (events.js:213:7)
3381 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
3381 verbose stack at emitTwo (events.js:125:13)
3381 verbose stack at ChildProcess.emit (events.js:213:7)
3381 verbose stack at maybeClose (internal/child_process.js:927:16)
3381 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
3382 verbose pkgid grpc@1.7.2
3383 verbose cwd /app
3384 verbose Linux 4.4.0-101-generic
3385 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "firebase"
3386 verbose node v8.5.0
3387 verbose npm v5.3.0
3388 error code ELIFECYCLE
3389 error errno 1
3390 error grpc@1.7.2 install: `node-pre-gyp install --fallback-to-build --library=static_library`
3390 error Exit status 1
3391 error Failed at the grpc@1.7.2 install script.
3391 error This is probably not a problem with npm. There is likely additional logging output above.
3392 verbose exit [ 1, true ]
环境:
OS: Ubuntu 16.04
npm: 5.3.0
节点:8.5.0
更新:
这个答案让我能够启动我的应用程序并 运行 在我的 alpine 容器中。在您的开发环境中尝试 运行 此代码。希望这有帮助。
Ran into the same issue this morning. Looks like the precompiled grpc1.7.2 hasn't been uploaded for musl based distributions (alpine is musl vs glibc)
For the short term, to get your build going again, and until they upload the precompiled versions, try adding this to your dockerfile
apk update && apk upgrade && apk add --no-cache python make g++
python, make and g++ basically allow node-gyp to compile from source rather than >relying on the precompiled versions
我在创建 docker 图像时遇到了同样的问题 运行。我注意到在使用 Linux-alpine 节点基础图像时,出现了这个错误。然而, 使用标准节点(我认为 Ubuntu 14.04)基本图像时它工作正常。 OS 你在用什么?希望你能找到解决办法!