尝试安装模块时不断出现 gyp 错误

问题描述 投票:0回答:1

当我尝试安装 npm 时收到这些错误。 这似乎是 gyp 的错误

npm ERR! code 1
npm ERR! path /Users/marcjensen/Documents/Skole/Praktik/gammel hjemmeside test/HOL/SourceCode/Main/Web/node_modules/rich-filemanager/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/local/bin/node /Users/marcjensen/Documents/Skole/Praktik/gammel hjemmeside test/HOL/SourceCode/Main/Web/node_modules/rich-filemanager/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/usr/local/bin/node',
npm ERR! gyp verb cli   '/Users/marcjensen/Documents/Skole/Praktik/gammel hjemmeside test/HOL/SourceCode/Main/Web/node_modules/rich-filemanager/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "/usr/local/bin/python3" in the PATH
npm ERR! gyp verb `which` succeeded /usr/local/bin/python3 /usr/local/bin/python3
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: Command failed: /usr/local/bin/python3 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm ERR! gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
npm ERR! gyp ERR! stack 
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:419:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
npm ERR! gyp ERR! stack     at Socket.<anonymous> (node:internal/child_process:449:11)
npm ERR! gyp ERR! stack     at Socket.emit (node:events:514:28)
npm ERR! gyp ERR! stack     at Pipe.<anonymous> (node:net:323:12)
npm ERR! gyp ERR! System Darwin 22.6.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/marcjensen/Documents/Skole/Praktik/gammel hjemmeside test/HOL/SourceCode/Main/Web/node_modules/rich-filemanager/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Users/marcjensen/Documents/Skole/Praktik/gammel hjemmeside test/HOL/SourceCode/Main/Web/node_modules/rich-filemanager/node_modules/node-sass
npm ERR! gyp ERR! node -v v18.17.1
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok 
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in: /Users/marcjensen/.npm/_logs/2023-09-20T09_41_33_777Z-debug-0.log

我尝试删除并安装node_modules。我尝试安装 python 2 和 python。 似乎什么都不起作用。你有什么建议吗?

npm npm-scripts
1个回答
0
投票

根据我的经验,这通常是由于您计算机上的 Python 版本与您正在使用的节点版本不匹配所致。我注意到有时我的 Mac 上的 Python 版本会在系统更新后自动更新。

© www.soinside.com 2019 - 2024. All rights reserved.