ubuntu 安装Node JS包时出现错误

sqxo8psd  于 2023-06-21  发布在  其他
关注(0)|答案(2)|浏览(194)

我想在Ubuntu上安装Maitrain。在这个过程中,我安装了Node包。但安装时出现错误。有人知道如何解决这个问题吗?

cd /var/www/mailtrain
sudo npm install --no-progress --production --unsafe-perm=true

During the Npm install I get a lot of errors then mailtrain service could not be started.

> posix@4.1.2 install /var/www/mailtrain/node_modules/posix
> node-gyp rebuild

Traceback (most recent call last):
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 13, in <module>
    import gyp
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 8, in <module>
    import gyp.input
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 5, in <module>
    from compiler.ast import Const
ImportError: No module named compiler.ast
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.15.0-66-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/mailtrain/node_modules/posix
gyp ERR! node -v v8.16.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN ajv-keywords@2.1.1 requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: posix@4.1.2 (node_modules/posix):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: posix@4.1.2 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

audited 15116 packages in 16.491s
found 85 vulnerabilities (26 low, 16 moderate, 38 high, 5 critical)
  run `npm audit fix` to fix them, or `npm audit` for details

   ╭────────────────────────────────────────────────────────────────╮
   │                                                                │
   │       New minor version of npm available! 6.4.1 → 6.13.4       │
   │   Changelog: https://github.com/npm/cli/releases/tag/v6.13.4   │
   │               Run npm install -g npm to update!                │
   │                                                                │
   ╰────────────────────────────────────────────────────────────────╯
g6baxovj

g6baxovj1#

这个特定的节点版本为我工作了同样的错误,其他版本在我的机器上与node-gyp兼容性有问题

12.14.1

参考:https://github.com/nodejs/node-gyp/issues/2031

epggiuax

epggiuax2#

据我所知,Ubuntu在安装node时安装了python2.7-minimal,并且包中不包含ast模块。安装python-2.7

apt install python-2.7

相关问题