【问题标题】:npm or yarn, `node-gyp rebuild` npm ERR! Exit status 1npm 或纱线,`node-gyp 重建` npm ERR!退出状态 1
【发布时间】:2020-07-14 11:07:07
【问题描述】:

我在 windows 中使用 yarn,我尝试过:12.13.1、*10.16.0(当前使用 64 位可执行文件)、9.11.2,我收到此错误:

error C:\XXX\node_modules\node-expat: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: C:\XXX\node_modules\node-expat
Output:
C:\XXX\node_modules\node-expat>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.16.0 | win32 | x64
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Program Files (x86)\Python37-32\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:982:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\XXX\node_modules\node-expat

不要理解消息。我可以看到 node_modules 文件夹已创建,但这发生在整个过程的“链接”步骤结束时。使用 npm 也会发生同样的情况。

我一直在尝试: - 使用纱线或 npm - 删除锁定文件 - 删除 node_modules 文件夹

总是同样的错误。有什么想法吗?

使用 npm 我得到了这个消息:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-expat@2.3.18 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat@2.3.18 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!     C:\Users\paulo.miranda\AppData\Roaming\npm-cache\_logs\2020-04-02T12_32_03_383Z-debug.log

【问题讨论】:

    标签: npm node-modules yarnpkg


    【解决方案1】:
     C:\Program Files (x86)\Python37-32\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
    

    构建过程正在尝试使用 python3 运行 python2 代码(例如 print "...")(应该是 print("...")

    您可以尝试安装 python2(但自 2020 年 1 月起不再支持),并强制安装过程运行 python2。

    或者,您可以尝试更新本地 python 安装并重试。

    【讨论】:

      【解决方案2】:

      当我使用 yarn install 时,我在 node-gyp 重建时遇到了一个相对相同的错误(我假设这与 npm install 的行为相同)。在我挠了 10 多个小时后,看来这可能是您的文件夹名称的原因。

      在我的情况下,我在文件夹名称上使用了空格(例如:"John Dog"),这会导致严重的问题,但请参阅此答案https://stackoverflow.com/a/33739586/14162468 我重命名了文件夹并删除了空格,voila 问题就解决了。我建议您尝试更改您的文件夹名称(paulo.miranda),因为. 可能会像我的情况一样导致错误

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-06-08
        • 2019-06-28
        • 1970-01-01
        • 2020-10-23
        • 2023-03-17
        • 2019-11-08
        • 2021-09-10
        • 2020-04-26
        相关资源
        最近更新 更多