【问题标题】:NPM Error when installing packages of a new project安装新项目的包时出现 NPM 错误
【发布时间】:2022-01-18 18:04:23
【问题描述】:

当我尝试从项目安装软件包时遇到了这个错误。 昨天我尝试并完美地工作,但今天我面临这个问题。我试图从另一个项目安装包,它工作正常。我真的不明白问题是出在我的 npm 版本还是什么的,但我几乎可以肯定我从昨天到今天没有改变任何东西。

知道它有什么关系吗? 提前致谢!

➜  backend git:(main) ✗ npm install
npm WARN deprecated natives@1.1.6: This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.3.2: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm ERR! code 1
npm ERR! path /Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! CC(target) Release/obj.target/libargon2/argon2/src/ref.o
npm ERR!   CC(target) Release/obj.target/libargon2/argon2/src/argon2.o
npm ERR!   CC(target) Release/obj.target/libargon2/argon2/src/core.o
npm ERR!   CC(target) Release/obj.target/libargon2/argon2/src/blake2/blake2b.o
npm ERR!   CC(target) Release/obj.target/libargon2/argon2/src/thread.o
npm ERR!   CC(target) Release/obj.target/libargon2/argon2/src/encoding.o
npm ERR!   LIBTOOL-STATIC Release/argon2.a
npm ERR!   CXX(target) Release/obj.target/argon2/src/argon2_node.o
npm ERR! Failed to execute '/Users/alansanchez/.nvm/versions/node/v16.2.0/bin/node /Users/alansanchez/.nvm/versions/node/v16.2.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2/lib/binding/napi-v3/argon2.node --module_name=argon2 --module_path=/Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2/lib/binding/napi-v3 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.8
npm ERR! node-pre-gyp info using node@16.2.0 | darwin | arm64
npm ERR! node-pre-gyp info check checked for "/Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2/lib/binding/napi-v3/argon2.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/ranisalt/node-argon2/releases/download/v0.27.2/argon2-v0.27.2-napi-v3-darwin-arm64-unknown.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/ranisalt/node-argon2/releases/download/v0.27.2/argon2-v0.27.2-napi-v3-darwin-arm64-unknown.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for argon2@0.27.2 and node@16.2.0 (node-v93 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/ranisalt/node-argon2/releases/download/v0.27.2/argon2-v0.27.2-napi-v3-darwin-arm64-unknown.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.2.0 | darwin | arm64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.2.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.8.9 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
npm ERR! gyp info spawn /Applications/Xcode.app/Contents/Developer/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/alansanchez/.nvm/versions/node/v16.2.0/lib/node_modules/npm/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/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/alansanchez/.nvm/versions/node/v16.2.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/alansanchez/Library/Caches/node-gyp/16.2.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/alansanchez/Library/Caches/node-gyp/16.2.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/alansanchez/.nvm/versions/node/v16.2.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/alansanchez/Library/Caches/node-gyp/16.2.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2',
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! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.2.0 | darwin | arm64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! clang: error: no such file or directory: 'Files/stylexchange-web-app/backend/node_modules/node-addon-api'
npm ERR! make: *** [Release/obj.target/argon2/src/argon2_node.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/alansanchez/.nvm/versions/node/v16.2.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:365:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 21.2.0
npm ERR! gyp ERR! command "/Users/alansanchez/.nvm/versions/node/v16.2.0/bin/node" "/Users/alansanchez/.nvm/versions/node/v16.2.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2/lib/binding/napi-v3/argon2.node" "--module_name=argon2" "--module_path=/Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2/lib/binding/napi-v3" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
npm ERR! gyp ERR! cwd /Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2
npm ERR! gyp ERR! node -v v16.2.0
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/Users/alansanchez/.nvm/versions/node/v16.2.0/bin/node /Users/alansanchez/.nvm/versions/node/v16.2.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2/lib/binding/napi-v3/argon2.node --module_name=argon2 --module_path=/Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2/lib/binding/napi-v3 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:365:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1067:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System Darwin 21.2.0
npm ERR! node-pre-gyp ERR! command "/Users/alansanchez/.nvm/versions/node/v16.2.0/bin/node" "/Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2
npm ERR! node-pre-gyp ERR! node -v v16.2.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.8
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/.npm/_logs/2022-01-18T09_06_02_542Z-debug.log

编辑: 这是package.json:

{
  "name": "backend",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "nodemon server",
    "start": "node server.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@prisma/client": "^3.2.1",
    "@sentry/node": "^6.2.2",
    "@sentry/tracing": "^6.2.2",
    "argon2": "^0.27.2",
    "aws-sdk": "^2.918.0",
    "axios": "^0.24.0",
    "bcryptjs": "^2.4.3",
    "colors": "^1.4.0",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "dotnet": "^1.1.4",
    "expo-server-sdk": "^3.6.0",
    "express": "^4.17.1",
    "express-async-handler": "^1.1.4",
    "firebase-admin": "^9.12.0",
    "http-proxy-middleware": "^1.0.6",
    "iban": "0.0.14",
    "ibantools": "^3.3.0",
    "ioredis": "^4.24.2",
    "jsonwebtoken": "^8.5.1",
    "lit-html": "^1.3.0",
    "moment": "^2.29.1",
    "moment-timezone": "^0.5.33",
    "multer": "^1.4.2",
    "nanoid": "^3.1.23",
    "natives": "^1.1.6",
    "node-fetch": "^2.6.1",
    "nodemailer": "^6.5.0",
    "objects-to-csv": "^1.3.6",
    "openpgp": "^5.0.1",
    "prisma-offset-pagination": "^0.0.4",
    "pug": "^3.0.2",
    "query-string": "^7.0.0",
    "redis": "^3.0.2",
    "socket.io": "^4.2.0",
    "stringify-object": "^4.0.0",
    "stripe": "^8.145.0",
    "uuidv4": "^6.2.12"
  },
  "devDependencies": {
    "prisma": "^3.2.1"
  }
}

【问题讨论】:

  • 首先,删除node_nodules,然后重试。如果这无助于分享package.json,则似乎某个模块已被弃用,必须更新。
  • 未创建 node_modules 文件夹。我克隆了项目并尝试安装软件包作为开始,但没有成功。包是:
  • 请不要将代码放入cmets,看起来很乱。您可以更新您的问题并删除 cmets。
  • 抱歉,第一次使用平台。感谢您的评论!我已经编辑了问题:)

标签: node.js npm package npm-install


【解决方案1】:

似乎argon2 包由于安全原因而出现问题。如果你删除它,安装就可以了。

您可以尝试运行以下命令吗? :

 npm remove argon2
 npm install argon2@latest

更新包后应该可以正常运行npm install.

如果这不起作用,我建议在 argon2 github repository 上打开一个问题,或者根据您的需要使用其他一些哈希模块。

错误信息

如果您仔细查看错误消息,您会看到以下指示问题的路径:

npm ERR! path /Users/alansanchez/Desktop/SXC Files/stylexchange-web-app/backend/node_modules/argon2

它指向argon2,所以你有一个提示是什么问题

【讨论】:

  • 非常感谢!!!!我不敢相信问题只是路径中文件夹名称中的空格! :(。我花了大约 3 个小时试图解决这个问题!。你是救生员,Silvan!再次感谢!
猜你喜欢
  • 2022-07-25
  • 2019-04-21
  • 1970-01-01
  • 2019-05-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-03
相关资源
最近更新 更多