为什么我不能在Ubuntu 18.04.1上安装npm软件包?

时间:2018-11-05 00:25:49

标签: node.js npm ubuntu-18.04

我正在尝试在Ubuntu 18.04.01上为节点安装mysql,nodejs以及express和mysql模块,这是我正在逐步进行的工作:

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

1 个答案:

答案 0 :(得分:0)

在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