为什么在 macOS Catalina 上尝试为 Angular 项目运行 npm install 时会出现这些失败?
2020-01-16
6556
我有一个现有的 angular 项目,几个月前刚刚开始运行,并签入了 git repo。我买了一台运行 Catalina 的新 MacBook,全局安装了 node 和 angular cli。从 git repo 克隆项目后,我运行了“npm install”,但安装失败。有人能帮我解决这个问题吗?这似乎涉及到 angular 和 node 的深度,我对此还不太熟悉。这是输出:
user@mbp (master)-> npm install
> [email protected] install /Users/username/Development/angular/idea-portal/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.23.3/node-v79-darwin-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v79 ABI, unknown) (falling back to source compile with node-gyp)
CXX(target)Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/resolver_registry.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/resolver_result_parsing.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/resolving_lb_policy.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/retry_throttle.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/server_address.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/service_config.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/subchannel.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/subchannel_pool_interface.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/deadline/deadline_filter.o
CC(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/health/health.pb.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/tsi/fake_transport_security.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/tsi/local_transport_security.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_boringssl.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_cache.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/tsi/ssl/session_cache/ssl_session_openssl.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/tsi/ssl_transport_security.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/tsi/transport_security_grpc.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/transport/chttp2/server/chttp2_server.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/transport/chttp2/client/secure/secure_channel_create.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/transport/chttp2/server/insecure/server_chttp2.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/transport/inproc/inproc_plugin.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/transport/inproc/inproc_transport.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.o
CC(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.o
CC(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.o
CC(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/xds/xds.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.o
CXX(target)Release/obj.target/grpc/deps/grpc/src/core/ext/filters/message_size/message_size_filter.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/http/client_authority_filter.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/ext/filters/workarounds/workaround_utils.o
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/plugin_registry/grpc_plugin_registry.o
LIBTOOL-STATIC Release/libgrpc.a
CXX(target) Release/obj.target/gpr/deps/grpc/src/core/lib/gpr/alloc.o
CXX(target) Release/obj.target/gpr/deps/grpc/src/core/lib/gpr/atm.o
CXX(target) Release/obj.target/gpr/deps/grpc/src/core/lib/gpr/cpu_iphone.o
Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_parse_txt_reply.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_platform.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_process.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_query.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_search.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_send.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_strcasecmp.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_strdup.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_strerror.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_strsplit.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_timeout.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_version.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/ares_writev.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/bitncmp.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/inet_net_pton.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/inet_ntop.o
CC(target) Release/obj.target/ares/deps/grpc/third_party/cares/cares/windows_port.o
LIBTOOL-STATIC Release/libares.a
CC(target) Release/obj.target/address_sorting/deps/grpc/third_party/address_sorting/address_sorting.o
CC(target) Release/obj.target/address_sorting/deps/grpc/third_party/address_sorting/address_sorting_posix.o
CC(target) Release/obj.target/address_sorting/deps/grpc/third_party/address_sorting/address_sorting_windows.o
LIBTOOL-STATIC Release/libaddress_sorting.a
CXX(target) Release/obj.target/grpc_node/ext/byte_buffer.o
CXX(target) Release/obj.target/grpc_node/ext/call.o
../ext/call.cc:104:53: error: no matching member function for call to 'Get'
Local<String> current_key(Nan::To<String>(keys->Get(i)).ToLocalChecked());
~~~~~~^~~
/Users/username/Library/Caches/node-gyp/13.6.0/include/node/v8.h:3594:43: note: candidate function not viable: requires 2 arguments, but 1 was provided
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
^
/Users/username/Library/Caches/node-gyp/13.6.0/include/node/v8.h:3597:43: note: candidate function not viable: requires 2 arguments, but 1 was provided
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
^
../ext/call.cc:681:27: error: no matching member function for call to 'Get'
if (!op->ParseOp(obj->Get(type), &ops[i])) {
~~~~~^~~
/Users/username/Library/Caches/node-gyp/13.6.0/include/node/v8.h:3594:43: note: candidate function not viable: requires 2 arguments, but 1 was provided
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
^
/Users/username/Library/Caches/node-gyp/13.6.0/include/node/v8.h:3597:43: note: candidate function not viable: requires 2 arguments, but 1 was provided
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
^
2 errors generated.
make: *** [Release/obj.target/grpc_node/ext/call.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:321:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/usr/local/Cellar/node/13.6.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--library=static_library" "--module=/Users/username/Development/angular/idea-portal/node_modules/grpc/src/node/extension_binary/node-v79-darwin-x64-unknown/grpc_node.node" "--module_name=grpc_node" "--module_path=/Users/username/Development/angular/idea-portal/node_modules/grpc/src/node/extension_binary/node-v79-darwin-x64-unknown" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v79"
gyp ERR! cwd /Users/username/Development/angular/idea-portal/node_modules/grpc
gyp ERR! node -v v13.6.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/13.6.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/Users/username/Development/angular/idea-portal/node_modules/grpc/src/node/extension_binary/node-v79-darwin-x64-unknown/grpc_node.node --module_name=grpc_node --module_path=/Users/username/Development/angular/idea-portal/node_modules/grpc/src/node/extension_binary/node-v79-darwin-x64-unknown --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v79' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/username/Development/angular/idea-portal/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:321:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1028:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Darwin 19.2.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/13.6.0/bin/node" "/Users/username/Development/angular/idea-portal/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /Users/username/Development/angular/idea-portal/node_modules/grpc
node-pre-gyp ERR! node -v v13.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/Cellar/node/13.6.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/Users/username/Development/angular/idea-portal/node_modules/grpc/src/node/extension_binary/node-v79-darwin-x64-unknown/grpc_node.node --module_name=grpc_node --module_path=/Users/username/Development/angular/idea-portal/node_modules/grpc/src/node/extension_binary/node-v79-darwin-x64-unknown --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v79' (1)
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of jasmine-core@>=3.5 but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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/username/.npm/_logs/2020-01-16T20_34_52_595Z-debug.log
Angular CLI: 8.3.22
Node: 13.6.0
OS: darwin x64
Angular: 8.0.3
... common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.800.6
@angular-devkit/build-angular 0.800.6
@angular-devkit/build-optimizer 0.800.6
@angular-devkit/build-webpack 0.800.6
@angular-devkit/core 8.0.6
@angular-devkit/schematics 8.3.22
@angular/animations 8.2.14
@angular/cdk 8.2.3
@angular/cli 8.3.22
@angular/fire 5.3.0
@angular/material 8.2.3
@ngtools/webpack 8.0.6
@schematics/angular 8.3.22
@schematics/update 0.803.22
rxjs 6.4.0
typescript 3.4.5
webpack 4.30.0
我正在运行最新版本的 macOs Catalina
当我使用“ng new”创建新项目时,我还收到了关于 core-js@3 的奇怪警告,但生成的新 Angular 项目确实可以编译并运行:
username@mbp-> ng new test
? Would you like to add Angular routing? Yes
? Which stylesheet format would you like to use? CSS
CREATE test/README.md (1022 bytes)
CREATE test/.editorconfig (246 bytes)
CREATE test/.gitignore (631 bytes)
CREATE test/angular.json (3577 bytes)
CREATE test/package.json (1290 bytes)
CREATE test/tsconfig.json (543 bytes)
CREATE test/tslint.json (1953 bytes)
CREATE test/browserslist (429 bytes)
CREATE test/karma.conf.js (1016 bytes)
CREATE test/tsconfig.app.json (270 bytes)
CREATE test/tsconfig.spec.json (270 bytes)
CREATE test/src/favicon.ico (948 bytes)
CREATE test/src/index.html (290 bytes)
CREATE test/src/main.ts (372 bytes)
CREATE test/src/polyfills.ts (2838 bytes)
CREATE test/src/styles.css (80 bytes)
CREATE test/src/test.ts (642 bytes)
CREATE test/src/assets/.gitkeep (0 bytes)
CREATE test/src/environments/environment.prod.ts (51 bytes)
CREATE test/src/environments/environment.ts (662 bytes)
CREATE test/src/app/app-routing.module.ts (246 bytes)
CREATE test/src/app/app.module.ts (393 bytes)
CREATE test/src/app/app.component.css (0 bytes)
CREATE test/src/app/app.component.html (25530 bytes)
CREATE test/src/app/app.component.spec.ts (1092 bytes)
CREATE test/src/app/app.component.ts (208 bytes)
CREATE test/e2e/protractor.conf.js (808 bytes)
CREATE test/e2e/tsconfig.json (214 bytes)
CREATE test/e2e/src/app.e2e-spec.ts (637 bytes)
CREATE test/e2e/src/app.po.ts (262 bytes)
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
> [email protected] install /Users/username/Development/angular/test/node_modules/@angular/compiler-cli/node_modules/fsevents
> node-gyp rebuild
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
> [email protected] install /Users/jusername/Development/angular/test/node_modules/karma/node_modules/fsevents
> node-gyp rebuild
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
> [email protected] install /Users/username/Development/angular/test/node_modules/watchpack/node_modules/fsevents
> node-gyp rebuild
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
> [email protected] install /Users/username/Development/angular/test/node_modules/webpack-dev-server/node_modules/fsevents
> node-gyp rebuild
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
> [email protected] postinstall /Users/username/Development/angular/test/node_modules/core-js
> node scripts/postinstall || echo "ignore"
> [email protected] postinstall /Users/username/Development/angular/test/node_modules/karma/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> @angular/[email protected] postinstall /Users/username/Development/angular/test/node_modules/@angular/cli
> node ./bin/postinstall/script.js
npm WARN [email protected] requires a peer of jasmine-core@>=3.5 but none is installed. You must install peer dependencies yourself.
added 1443 packages from 1068 contributors and audited 19051 packages in 34.442s
23 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Successfully initialized git.
我不确定是什么导致了这一切。看来 node 和 angular cli 的安装成功了。
2个回答
- 尝试删除“node_modules”文件夹,然后再次“npm install”。
- 检查“.npmrc”配置
drfrontend 1
2020-01-16
此问题已解决。node-gyp 目前不支持最新的 nodejs (v13),因此回滚到 v12 即可解决问题。
u84six
2020-01-17