gpt4 book ai didi

node.js - 为什么无法在 Ubuntu 18.04.1 上安装 npm 软件包?

转载 作者:太空宇宙 更新时间:2023-11-03 22:22:12 25 4
gpt4 key购买 nike

我正在尝试在 Ubuntu 18.04.01 上为 Node 安装 mysql、nodejs、express 和 mysql 模块,这就是我正在逐步执行的操作:

  1. 安装ubuntu
  2. sudo apt-add-repository Universe && sudo apt update && sudo apt -y 升级
  3. sudo apt -y install failure2ban mysql-server build-essential
  4. sudo ufw 允许 OpenSSH && sudo ufw 启用
  5. sudo mysql_secure_installation
  6. 将 mysql_native_password 标识的用户“root”@“localhost”更改为“xxxxxxxxxxxxxxxxxxxx”;刷新权限;
  7. curl -sL https://deb.nodesource.com/setup_10.x | curl -sL ojit_a | sudo -E bash - && sudo apt-get install -y nodejs
  8. mkdir nodedbtest && cd nodedbtest
  9. 触摸index.js
  10. npm 初始化
  11. npm 安装 Express

在执行 #11 后,我收到此错误:

npm ERR! code ERR_INVALID_OPT_VALUE
npm ERR! The value "4294967295" is invalid for option "family"

npm ERR! A complete log of this run can be found in:
npm ERR! /home/willdorf/.npm/_logs/2018-11-05T00_14_18_703Z-debug.log

这是日志:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', 'mysql' ]
2 info using npm@6.4.1
3 info using node@v10.13.0
4 verbose npm-session 2456a42eb4ea509e
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for mysql@latest The value "4294967295" is invalid for option "family"
8 timing stage:rollbackFailedOptional Completed in 14ms
9 timing stage:runTopLevelLifecycles Completed in 3340ms
10 verbose stack TypeError [ERR_INVALID_OPT_VALUE]: The value "4294967295" is invalid for option "family"
10 verbose stack at lookup (dns.js:113:11)
10 verbose stack at net.js:1006:5
10 verbose stack at defaultTriggerAsyncIdScope (internal/async_hooks.js:294:19)
10 verbose stack at lookupAndConnect (net.js:1005:3)
10 verbose stack at TLSSocket.Socket.connect (net.js:940:5)
10 verbose stack at Object.connect (_tls_wrap.js:1148:12)
10 verbose stack at HttpsAgent.createConnection (https.js:119:22)
10 verbose stack at HttpsAgent.createSocket (/usr/lib/node_modules/npm/node_modules/agentkeepalive/lib/_http_agent.js:265:26)
10 verbose stack at HttpsAgent.createSocket (/usr/lib/node_modules/npm/node_modules/agentkeepalive/lib/agent.js:77:11)
10 verbose stack at HttpsAgent.addRequest (/usr/lib/node_modules/npm/node_modules/agentkeepalive/lib/_http_agent.js:239:10)
10 verbose stack at new ClientRequest (_http_client.js:248:16)
10 verbose stack at request (https.js:280:10)
10 verbose stack at fetch.Promise (/usr/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:54:17)
10 verbose stack at new Promise (<anonymous>)
10 verbose stack at fetch (/usr/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:41:10)
10 verbose stack at retry (/usr/lib/node_modules/npm/node_modules/make-fetch-happen/index.js:332:14)
11 verbose cwd /home/willdorf/nodedbtest
12 verbose Linux 4.15.0-38-generic
13 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "mysql"
14 verbose node v10.13.0
15 verbose npm v6.4.1
16 error code ERR_INVALID_OPT_VALUE
17 error The value "4294967295" is invalid for option "family"
18 verbose exit [ 1, true ]

最佳答案

尝试以下在 Ubuntu 18.04.3 LTS 上对我有用的方法:

sudo dpkg --configure -a
sudo apt-add-repository universe && sudo apt update && sudo apt -y upgrade
sudo apt-get dist-upgrade
sudo apt --fix-broken install
sudo apt autoremove
sudo apt -y install fail2ban mysql-server build-essential
sudo ufw allow OpenSSH && sudo ufw enable
sudo mysql_secure_installation
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - && sudo apt-get install -y nodejs
mkdir nodedbtest && cd nodedbtest
touch index.js
npm init
npm install express

关于node.js - 为什么无法在 Ubuntu 18.04.1 上安装 npm 软件包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53146838/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com