我正在使用
npm i
提取 React 应用程序的依赖项,我得到:
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 "/home/mark/Downloads/offenderbook_web-master/client/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>
npm ERR! sys.exit(gyp.script_main())
npm ERR! File "/home/mark/Downloads/offenderbook_web-master/client/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main
npm ERR! return main(sys.argv[1:])
npm ERR! File "/home/mark/Downloads/offenderbook_web-master/client/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main
npm ERR! return gyp_main(args)
npm ERR! File "/home/mark/Downloads/offenderbook_web-master/client/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 514, in gyp_main
npm ERR! options.duplicate_basename_check)
npm ERR! File "/home/mark/Downloads/offenderbook_web-master/client/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 130, in Load
npm ERR! params['parallel'], params['root_targets'])
npm ERR! File "/home/mark/Downloads/offenderbook_web-master/client/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2783, in Load
npm ERR! variables, includes, depth, check, True)
npm ERR! File "/home/mark/Downloads/offenderbook_web-master/client/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 399, in LoadTargetBuildFile
npm ERR! includes, True, check)
npm ERR! File "/home/mark/Downloads/offenderbook_web-master/client/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 271, in LoadOneBuildFile
npm ERR! aux_data, includes, check)
npm ERR! File "/home/mark/Downloads/offenderbook_web-master/client/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 308, in LoadBuildFileIncludesIntoDict
npm ERR! LoadOneBuildFile(include, data, aux_data, None, False, check),
npm ERR! File "/home/mark/Downloads/offenderbook_web-master/client/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 251, in LoadOneBuildFile
npm ERR! None)
npm ERR! File "/home/mark/.node-gyp/20.0.0/include/node/common.gypi", line 1
npm ERR! erate ',
npm ERR! ^
npm ERR! SyntaxError: EOL while scanning string literal
npm ERR! gyp ERR! configure error
当我查看该文件时,它实际上是从第一行开始的
erate ',
所以我并不惊讶它会抛出错误。但为什么以及如何解决这个问题?
我需要更新版本的 Node 吗?我当前安装的是 20.0。
我可以重现这个问题 我无法解释为什么/如何文件像OP所描述的那样被损坏。
我做了 @jkmartindale 在他们的评论中建议的事情。
具体来说,我访问了nodejs下载/发布页面以找到与我当前的node版本相对应的链接(
node -v
)。
在我写这篇文章时,我的
node -v
是版本20.10.0
,所以我下载了它的node-v20.10.0-headers.tar.gz
文件并将其解压到位于.node-gyp
的~\.node-gyp\20.10.0\include\node
目录(对我来说,就是这样C:\Users\there\.node-gyp\20.10.0\include\node
)