我有一个Angular 应用程序,我正试图在我本地的Mac电脑上设置它.但是,当我使用NPM安装来安装依赖项时,我得到以下错误

npm ERR! code 1
npm ERR! path /Users/tum/Desktop/nx-pricing-sample/node_modules/@parcel/watcher
npm ERR! command failed
npm ERR! command sh -c -- node-gyp-build
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@16.19.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.12.0 found at "/Library/Frameworks/Python.framework/Versions/3.12/bin/python3"
npm ERR! (node:2058) \[DEP0150\] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! gyp info spawn /Library/Frameworks/Python.framework/Versions/3.12/bin/python3
npm ERR! gyp info spawn args \[
npm ERR! gyp info spawn args   '/Users/tum/Desktop/nx-pricing-sample/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   '/Users/tum/Desktop/nx-pricing-sample/node_modules/@parcel/watcher/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/tum/Desktop/nx-pricing-sample/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/tum/Library/Caches/node-gyp/16.19.0/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=/Users/tum/Library/Caches/node-gyp/16.19.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/tum/Desktop/nx-pricing-sample/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/tum/Library/Caches/node-gyp/16.19.0/\<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/tum/Desktop/nx-pricing-sample/node_modules/@parcel/watcher',
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! Traceback (most recent call last):
npm ERR!   File "/Users/tum/Desktop/nx-pricing-sample/node_modules/node-gyp/gyp/gyp_main.py", line 51, in \<module\>
npm ERR!     sys.exit(gyp.script_main())
npm ERR!              ^^^^^^^^^^^^^^^^^
npm ERR!   File "/Users/tum/Desktop/nx-pricing-sample/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 670, in script_main
npm ERR!     return main(sys.argv\[1:\])
npm ERR!            ^^^^^^^^^^^^^^^^^^
npm ERR!   File "/Users/tum/Desktop/nx-pricing-sample/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 662, in main
npm ERR!     return gyp_main(args)
npm ERR!            ^^^^^^^^^^^^^^
npm ERR!   File "/Users/tum/Desktop/nx-pricing-sample/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 629, in gyp_main
npm ERR!     \[generator, flat_list, targets, data\] = Load(
npm ERR!                                             ^^^^^
npm ERR!   File "/Users/tum/Desktop/nx-pricing-sample/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 150, in Load
npm ERR!     result = gyp.input.Load(
npm ERR!              ^^^^^^^^^^^^^^^
npm ERR!   File "/Users/tum/Desktop/nx-pricing-sample/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 3021, in Load
npm ERR!     LoadTargetBuildFile(
npm ERR!   File "/Users/tum/Desktop/nx-pricing-sample/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 411, in LoadTargetBuildFile
npm ERR!     build_file_data = LoadOneBuildFile(
npm ERR!                       ^^^^^^^^^^^^^^^^^
npm ERR!   File "/Users/tum/Desktop/nx-pricing-sample/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 239, in LoadOneBuildFile
npm ERR!     build_file_contents = open(build_file_path, "rU").read()
npm ERR!                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm ERR! ValueError: invalid mode: 'rU' while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/Users/tum/Desktop/nx-pricing-sample/node_modules/node-gyp/lib/configure.js:351:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess.\_handle.onexit (node:internal/child_process:293:12)
npm ERR! gyp ERR! System Darwin 22.1.0
npm ERR! gyp ERR! command "/Users/tum/.nvm/versions/node/v16.19.0/bin/node" "/Users/tum/Desktop/nx-pricing-sample/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/tum/Desktop/nx-pricing-sample/node_modules/@parcel/watcher
npm ERR! gyp ERR! node -v v16.19.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tum/.npm/\_logs/2022-12-17T06_03_21_928Z-debug-0.log

推荐答案

U模式已经弃用了一段时间,并最终在Python3.11中被删除.

不幸的是,gyp仍然使用这种模式,因此与Python3.10不兼容(例如,参见https://github.com/nodejs/node-gyp/blob/main/README.md#on-macos).降级到Python3.10应该可以解决这个问题.

Node.js相关问答推荐

在child_Process中持久运行SSH命令

如何处理EPIPE时,使用axios并期待413响应?

express返回意外的URL

如何在RavenDB中执行JS索引?

根据我的测试,为什么在编写Varint代码方面,NodeJS要比Rust快这么多?

如何在Sequelize with Postgres中将m:n关联表ID从整数迁移到UUID?

当 Got 包因错误 JSON 崩溃时如何获取响应文本?

npm 在 Windows 终端中不工作

为什么 nginx 不将我的 react index.html 作为后备服务

运行 cypress 测试时如何指定 .env 文件用于我的开发服务器?

为什么当我使用waitForSelector时 Puppeteer 导致我的测试套件挂起 30 秒,即使我在页面和浏览器上调用关闭?

Firestore promise 在退货前等待产品详细信息

如何在 Node.js 的 console.log() 中创建换行符

Passport 登录和持久会话

如何在 Joi 字符串验证中使用枚举值

如何在 MongoDB 中查询引用的对象?

nodejs v10.3.0 的 gulp 任务问题:src\node_contextify.cc:629: Assertion `args[1]->IsString()' failed

Node.js 连接仅适用于本地主机

如何设置 useMongoClient (Mongoose 4.11.0)?

将 expressjs 绑定到特定的 IP 地址