bash: npm: 在 cPanel 终端中找不到命令

发布于 2025-01-11 04:47:59 字数 722 浏览 0 评论 0原文

我得到回应,当尝试写:

$ /opt/cpanel/ea-nodejs16/bin/npm -v
8.1.2

但是使用:

$ npm -v
bash: npm: command not found

所以,我尝试了相同的逻辑,但它不起作用:

$ /opt/cpanel/ea-nodejs16/bin/npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/mydomain/public_html/app/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/mydomain/public_html/app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/mydomain/.npm/_logs/2022-03-02T14_43_55_155Z-debug.log

那么,如何使“npm”命令行在服务器上工作。

I get response, When try to write:

$ /opt/cpanel/ea-nodejs16/bin/npm -v
8.1.2

but with :

$ npm -v
bash: npm: command not found

So, I tried as the same logic but it didn't work:

$ /opt/cpanel/ea-nodejs16/bin/npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/mydomain/public_html/app/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/mydomain/public_html/app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/mydomain/.npm/_logs/2022-03-02T14_43_55_155Z-debug.log

So, how to make " npm " command lines works on server.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧时浪漫 2025-01-18 04:47:59

首先在 cPanel、WHM 上安装 NodeJS。

要从 WHM 安装 NodeJS,请转到 Home /
软件 /
EasyApache 4

在附加包中找到 NodeJS。

输入图片描述这里

之后创建一个指向节点目录的环境变量。
运行此命令即可执行此操作。

export PATH=/opt/cpanel/ea-nodejs16/bin/:$PATH

最后运行npm -v来检查NodeJS版本。

希望这对某人有帮助。

First install NodeJS install on cPanel, WHM.

To install NodeJS from WHM, Goto Home /
Software /
EasyApache 4

And in Additional Packages find NodeJS.

enter image description here

After that create an environment variable which points to the node directory.
Run this command to do that.

export PATH=/opt/cpanel/ea-nodejs16/bin/:$PATH

Finally run npm -v to check NodeJS version.

Hope this will help for someone.

桃酥萝莉 2025-01-18 04:47:59

您需要创建一个指向正确目录的环境变量。这应该可以完成工作:

export PATH=/opt/cpanel/ea-nodejs16/bin/:$PATH

或者将其添加到您的 .bashrc 文件中以保持其持久性。关于您收到的 npm 错误,正如 jordanm 提到的,您当前目录中没有 package.json 文件。

You need to create an environment variable which points to the right directory. This should do the job:

export PATH=/opt/cpanel/ea-nodejs16/bin/:$PATH

or add it to your .bashrc file to keep it persistent. And regarding this npm error you get, as jordanm mentioned you don't have package.json file in you current directory.

隔纱相望 2025-01-18 04:47:59

您必须将路径存储在 .bashrc 文件中。您可以通过运行以下命令轻松完成。

echo export PATH=/opt/cpanel/ea-nodejs16/bin/:$PATH

You have to store the path inside in your .bashrc file. You can do it easily by run following command.

echo export PATH=/opt/cpanel/ea-nodejs16/bin/:$PATH
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文