Ubuntu 22.04下apt安装node-acorn时依赖冲突问题求助
各位好,我在Ubuntu 22.04上执行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.5dfsg-4) but 18.14.2-deb-1nodesource1 is to be installed
E: Unable to correct problems, you have held broken packages.
我的系统是Ubuntu 22.04,当前装的Node.js是18.14.2版本(来自Nodesource源,因为Ubuntu官方源里的Node.js版本实在太旧)。虽然我已经通过npm安装了acorn,但我需要安装emscripten,它依赖的是apt包管理的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 ubuntu-devel-discuss@lists.ubuntu.com
Original-Maintainer: Debian Javascript Maintainers pkg-javascript-devel@lists.alioth.debian.org
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.5dfsg-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,彻底卸载Node.js后从Canonical官方源重新安装(在22.04里不得不选Nodesource源,就是因为官方源版本太老)。但还是想知道在Ubuntu 22.04下有没有更合适的解决方式,求各位大佬给点建议!
备注:内容来源于stack exchange,提问作者Iiro Ullin

