node.js - NPM 在通过 apt 安装时需要 x11

标签 node.js ubuntu npm x11 xserver

我运行 Ubuntu 服务器 20.04,我需要安装 npm。
但是当我运行“apt install npm”时,我在需求中看到了 x11 包。

The following NEW packages will be installed:
  gyp javascript-common libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libfile-basedir-perl libfile-desktopentry-perl libfile-mimeinfo-perl libfontenc1
  libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libice6 libipc-system-simple-perl libjs-inherits libjs-is-typedarray libjs-psl
  libjs-typedarray-to-buffer libllvm11 libnet-dbus-perl libnode-dev libpciaccess0 libsm6 libtie-ixhash-perl libuv1-dev libvulkan1 libwayland-client0
  libx11-protocol-perl libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-shape0 libxcb-sync1 libxcb-xfixes0
  libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxft2 libxi6 libxinerama1 libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl libxmu6 libxrandr2
  libxshmfence1 libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 mesa-vulkan-drivers node-abbrev node-ajv node-ansi node-ansi-align node-ansi-regex node-ansi-styles
  node-ansistyles node-aproba node-archy node-are-we-there-yet node-asap node-asn1 node-assert-plus node-asynckit node-aws-sign2 node-aws4 node-balanced-match
  node-bcrypt-pbkdf node-bl node-bluebird node-boxen node-brace-expansion node-builtin-modules node-builtins node-cacache node-call-limit node-camelcase node-caseless
  node-chalk node-chownr node-ci-info node-cli-boxes node-cliui node-clone node-co node-color-convert node-color-name node-colors node-columnify node-combined-stream
  node-concat-map node-concat-stream node-config-chain node-configstore node-console-control-strings node-copy-concurrently node-core-util-is node-cross-spawn
  node-crypto-random-string node-cyclist node-dashdash node-debug node-decamelize node-decompress-response node-deep-extend node-defaults node-define-properties
  node-delayed-stream node-delegates node-detect-indent node-detect-newline node-dot-prop node-duplexer3 node-duplexify node-ecc-jsbn node-editor node-encoding
  node-end-of-stream node-err-code node-errno node-es6-promise node-escape-string-regexp node-execa node-extend node-extsprintf node-fast-deep-equal node-find-up
  node-flush-write-stream node-forever-agent node-form-data node-from2 node-fs-vacuum node-fs-write-stream-atomic node-fs.realpath node-function-bind node-gauge
  node-genfun node-get-caller-file node-get-stream node-getpass node-glob node-got node-graceful-fs node-gyp node-har-schema node-har-validator node-has-flag
  node-has-symbol-support-x node-has-to-string-tag-x node-has-unicode node-hosted-git-info node-http-signature node-iconv-lite node-iferr node-import-lazy
  node-imurmurhash node-inflight node-inherits node-ini node-invert-kv node-ip node-ip-regex node-is-npm node-is-obj node-is-object node-is-path-inside
  node-is-plain-obj node-is-retry-allowed node-is-stream node-is-typedarray node-isarray node-isexe node-isstream node-isurl node-jsbn node-json-parse-better-errors
  node-json-schema node-json-schema-traverse node-json-stable-stringify node-json-stringify-safe node-jsonify node-jsonparse node-jsonstream node-jsprim
  node-latest-version node-lazy-property node-lcid node-libnpx node-locate-path node-lockfile node-lodash node-lodash-packages node-lowercase-keys node-lru-cache
  node-make-dir node-mem node-mime node-mime-types node-mimic-fn node-mimic-response node-minimatch node-minimist node-mississippi node-mkdirp node-move-concurrently
  node-ms node-mute-stream node-nopt node-normalize-package-data node-npm-bundled node-npm-package-arg node-npm-run-path node-npmlog node-number-is-nan
  node-oauth-sign node-object-assign node-once node-opener node-os-locale node-os-tmpdir node-osenv node-p-cancelable node-p-finally node-p-is-promise node-p-limit
  node-p-locate node-p-timeout node-package-json node-parallel-transform node-path-exists node-path-is-absolute node-path-is-inside node-performance-now node-pify
  node-prepend-http node-process-nextick-args node-promise-inflight node-promise-retry node-promzard node-proto-list node-prr node-pseudomap node-psl node-pump
  node-pumpify node-punycode node-qs node-qw node-rc node-read node-read-package-json node-readable-stream node-registry-auth-token node-registry-url node-request
  node-require-directory node-require-main-filename node-resolve node-resolve-from node-retry node-rimraf node-run-queue node-safe-buffer node-semver node-semver-diff
  node-set-blocking node-sha node-shebang-command node-shebang-regex node-signal-exit node-slash node-slide node-sorted-object node-spdx-correct node-spdx-exceptions
  node-spdx-expression-parse node-spdx-license-ids node-sshpk node-ssri node-stream-each node-stream-iterate node-stream-shift node-strict-uri-encode
  node-string-decoder node-string-width node-strip-ansi node-strip-eof node-strip-json-comments node-supports-color node-tar node-term-size node-text-table
  node-through node-through2 node-timed-out node-tough-cookie node-tunnel-agent node-tweetnacl node-typedarray node-typedarray-to-buffer node-uid-number
  node-unique-filename node-unique-string node-unpipe node-uri-js node-url-parse-lax node-url-to-options node-util-deprecate node-uuid
  node-validate-npm-package-license node-validate-npm-package-name node-verror node-wcwidth.js node-which node-which-module node-wide-align node-widest-line
  node-wrap-ansi node-wrappy node-write-file-atomic node-xdg-basedir node-xtend node-y18n node-yallist node-yargs node-yargs-parser npm x11-common x11-utils
  x11-xserver-utils xdg-utils
0 upgraded, 342 newly installed, 0 to remove and 121 not upgraded.
Need to get 38.2 MB of archives.
After this operation, 435 MB of additional disk space will be used.
Do you want to continue? [Y/n] ^C
但我不想在我的 Ubuntu 上安装 X 服务器。我完全不明白为什么 NPM 需要 X 服务器。没有 x11 有没有其他安装 NPM 的方法?

最佳答案

对于基于 Debian 和 Ubuntu 的发行版,请阅读 nodejs docs
虽然从 Ubuntu 存储库安装 nodejs 是可能的(nodejs 也可作为 snap 包提供),但我不建议使用 ubuntu repos 安装 nodejs 版本已过时.. 如果你是 snap 的粉丝,那么你可以使用 snap 安装最新版本的nodejs。
在 Ubuntu 上安装 nodejs(现在是 14.x 的 LTS 版本)的说明:

curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
然后更新:
sudo apt update
然后安装nodejs
sudo apt install -y nodejs
现在您可以检查 npm 版本:
npm --version
node --version 
还有一个用于安装不同版本 Node 的实用程序,称为 nvm。请看一下github

关于node.js - NPM 在通过 apt 安装时需要 x11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67147548/

相关文章:

node.js - Team Build 停止并等待 Gulp 任务完成

node.js - 为什么 Mongoose 总是在我的收藏名称末尾添加一个s

java gksudo 持久海拔

ubuntu - Solr,服务不可用 503

node.js - Mac OS Mavericks 上的 NPM 安装问题

npm install 命令在每一行给出错误

javascript - 将文本文件存储到内存中并访问它?

node.js - Webpack 如何构建生产代码以及如何使用它

php - 如何使nginx和php容器之间进行通信

node.js - 无法安装 grunt-contrib-imagemin(奇怪的错误 1)