使用 apt 安装 node-acorn 时出现的问题

使用 apt 安装 node-acorn 时出现的问题

尝试运行sudo apt install node-acorn会产生错误:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 node-acorn : Depends: nodejs:any or
                       nodejs (< 12.22.5~dfsg-4~) but 18.14.2-deb-1nodesource1 is to be installed
E: Unable to correct problems, you have held broken packages.

我使用的是 Ubuntu 22.04。我安装了最新的 LTS 版本 (18.14.2) 的 nodejs,但似乎我或 node-acorn 打包程序方面存在一些配置错误。我还通过 npm 安装了 acorn,但我想安装 emscripten,它有 node-acorn 作为依赖项(npm 副本似乎对它无关紧要)。您对如何解决此问题有什么建议吗?

以下是输出apt show node-acorn -a

Version: 8.7.0+ds+~cs24.17.6-1
Priority: optional
Section: universe/javascript
Source: acorn
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Debian Javascript Maintainers <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 972 kB
Provides: node-acorn-bigint (= 1.0.0), node-acorn-class-fields (= 1.0.0), node-acorn-dynamic-import (= 4.0.0), node-acorn-export-ns-from (= 0.2.0), node-acorn-globals (= 6.0.0), node-acorn-import-assertions (= 1.8.0), node-acorn-import-meta (= 1.1.0), node-acorn-jsx (= 5.3.1), node-acorn-loose (= 8.2.1), node-acorn-node (= 2.0.1), node-acorn-numeric-separator (= 0.3.4), node-acorn-private-class-elements (= 1.0.0), node-acorn-private-methods (= 1.0.0), node-acorn-static-class-features (= 1.0.0), node-acorn-walk (= 8.2.0), node-debbundle-acorn (= 8.7.0+ds+~cs24.17.6-1)
Depends: node-xtend, nodejs:any | nodejs (<< 12.22.5~dfsg-4~)
Breaks: node-acorn-dynamic-import (<< 4.0.0~), node-acorn-jsx (<< 5.0.0~), node-acorn-object-spread (<< 6~), node-babel (<< 7), node-debbundle-acorn (<< 8.5.0+ds+~cs24.17.6~), node-espree (<< 6~), node-falafel (<< 2.1.0-9~), webpack (<< 4.28.3~)
Replaces: node-acorn-dynamic-import (<< 4.0.0+really4.0.0~), node-acorn-jsx (<< 5.0.0~), node-debbundle-acorn (<< 8.5.0+ds+~cs24.17.6~)
Homepage: https://github.com/ternjs/acorn/
Download-Size: 117 kB
APT-Sources: http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
Description: ECMAScript parser for Node.js
 Acorn is a tiny, fast JavaScript parser written in JavaScript.
 .
 acorn.js defines the main parser interface. The library also comes with a
 error-tolerant parser and an abstract syntax tree walker, defined in other
 files.
 .
 This package contains the acorn module for Node.js.
 .
 This package contains also small pluggins packages acorn-bigint,
 acorn-dynamic-import, acorn-jsx, acorn-node, acorn-private-class-elements,
 acorn-class-fields, acorn-static-class-features, acorn-export-ns-from,
 acorn-numeric-separator, acorn-private-methods.
 .
 Node.js is an event-based server-side JavaScript engine.

我有解决了通过切换到 Ubuntu 20.10、清除 nodejs 安装并从 Canonical 的存储库而不是 Nodesource 的存储库重新安装来解决问题(必须使用带有 22.04 的 Nodesource,因为它的“本机”版本太旧了。)

相关内容