首页 > 解决方案 > 我无法安装特定的节点模块 [ejs]

问题描述

要学习 node.js,我想建立一个简单的网站。为此,我想使用 ejs。但是 ejs 的安装总是失败。我在多台机器上用不同的方法试过这个。在 npm 的设置中使用 Webstorms 内置方法并在网络服务器上使用 Plesk 我收到以下错误:

npm WARN lifecycle npm is using /opt/plesk/node/12/bin/node but there is no node binary in the current PATH. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
sh: node: command not found
npm WARN bootstrap@4.4.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.4.1 requires a peer of popper.js@^1.16.0 but none is installed. You must install peer dependencies yourself.
npm WARN project@1.0.0 No description
npm WARN project@1.0.0 No repository field.
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! ejs@3.1.2 postinstall: `node --harmony ./postinstall.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the ejs@3.1.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Webstorm 在我的本地机器上给了我一个非常相似的错误。我尝试过的任何其他 npm 包都可以正常工作。我安装了 express、bootstrap、jquery 等。问题似乎只出在 ejs 上。

我的 package.json 看起来像:

{
  "name": "project",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bootstrap": "^4.4.1",
    "express": "^4.17.1",
    "morgan": "^1.10.0"
  }
}

有什么建议么?一个问题是我只能在我的网络服务器上提供 Plesk 提供的功能,因为我无权以普通用户身份运行 node 或 npm。

标签: javascriptnode.jsejs

解决方案


npm WARN lifecycle npm is using /opt/plesk/node/12/bin/node but there is no node binary in the current PATH. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
sh: node: command not found

此错误描述了使用 plesk 时的解决方案,您正在使用哪个?另见

https://support.plesk.com/hc/en-us/articles/360000644114-Node-js-Run-Script-option-doesn-t-work-no-node-binary-in-the-current-PATH


推荐阅读