【问题标题】:What is causing a npm install nuxt error?是什么导致 npm install nuxt 错误?
【发布时间】:2021-09-06 05:06:23
【问题描述】:

我刚刚在运行 Ubuntu 20.04 的 WSL 上启动了 Nuxt 项目。

我正在使用 Node.js LTS/Fermium 并且我为项目安装了一些依赖项,但是当我尝试安装 Nuxt 本身时,它会检索到一些错误并且我找不到原因:

所以,当我执行npm install nuxt 时,会出现以下错误:

Debugger attached.
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path /home/tino/frontend/hanja/node_modules/deasync
npm ERR! command failed
npm ERR! command sh -c node ./build.js
npm ERR! Debugger attached.
npm ERR! Debugger attached.
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.3.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.8.5 found at "/usr/bin/python3"
npm ERR! (node:5914) [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 /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/tino/frontend/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   '/home/tino/frontend/hanja/node_modules/deasync/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/tino/frontend/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/tino/.cache/node-gyp/16.3.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=/home/tino/.cache/node-gyp/16.3.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/tino/frontend/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/tino/.cache/node-gyp/16.3.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/tino/frontend/hanja/node_modules/deasync',
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! Debugger attached.
npm ERR! Waiting for the debugger to disconnect...
npm ERR! gyp: Call to 'node -p "require('node-addon-api').include"' returned exit status 0 while in binding.gyp. 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 (/home/tino/frontend/node_modules/node-gyp/lib/configure.js:351:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Linux 5.4.72-microsoft-standard-WSL2
npm ERR! gyp ERR! command "/home/tino/.nvm/versions/node/v16.3.0/bin/node" "/home/tino/frontend/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/tino/frontend/hanja/node_modules/deasync
npm ERR! gyp ERR! node -v v16.3.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok 
npm ERR! Waiting for the debugger to disconnect...
npm ERR! Build failed
npm ERR! Waiting for the debugger to disconnect...

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/tino/.npm/_logs/2021-06-22T15_14_10_385Z-debug.log
Waiting for the debugger to disconnect...

我刚开始学习 Nuxt,但我不知道是什么导致了错误。

【问题讨论】:

  • home/tino/.npm/_logs/2021-06-22T15_14_10_385Z-debug.log 告诉你什么?如果简明日志没有足够的信息,请先查看实际日志,看看是否为您提供任何线索。 (因此,不要盲目地将该文件复制并粘贴到您的帖子中:先自己检查一下,看看它是否告诉您出了什么问题)。此外,如果您 安装 nuxt(确保它不在您的 package.json 等中),并且只运行 npm install,会发生什么情况?因为简洁的日志以许多行开头,表明您确实需要先更新一些依赖项。
  • 日志准确地显示了我在上面复制粘贴的错误。你是对的,我从 package.json 中删除了它,运行 npm install 并且出现了同样的错误。有什么线索可以从哪里来吗?这是我的第一个 WSL 项目,所以可能我的设置不正确。
  • 开始从 package.json 中移除依赖并重新运行 npm install。在某些时候,这个错误会消失,你删除的最后一个包就是你的问题。虽然我不知道你为什么不只是在普通的窗口中运行它,但 Node 工作得很好,你可能安装的几乎每个包也是如此。您可能需要安装 VC++ 以防万一需要从源代码编译任何内容,但如今几乎所有内容都有预构建的二进制文件,用于与特定平台相关的任何内容。

标签: node.js npm nuxt.js node-gyp


【解决方案1】:

我终于意识到我必须在 Ubuntu 中安装 build-essential 包,这会触发错误:

sudo apt-get install build-essential

之后我就可以安装 Nuxt 并且到目前为止一切都运行良好!

【讨论】:

    猜你喜欢
    • 2019-10-08
    • 2020-08-29
    • 1970-01-01
    • 2022-06-21
    • 2015-08-05
    • 2017-09-01
    • 1970-01-01
    • 2019-01-09
    • 1970-01-01
    相关资源
    最近更新 更多