bash: npm: 在 cPanel 终端中找不到命令
我得到回应,当尝试写:
$ /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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先在 cPanel、WHM 上安装 NodeJS。
要从 WHM 安装 NodeJS,请转到 Home /
软件 /
EasyApache 4
在附加包中找到 NodeJS。
之后创建一个指向节点目录的环境变量。
运行此命令即可执行此操作。
最后运行
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.
After that create an environment variable which points to the node directory.
Run this command to do that.
Finally run
npm -v
to check NodeJS version.Hope this will help for someone.
您需要创建一个指向正确目录的环境变量。这应该可以完成工作:
或者将其添加到您的
.bashrc
文件中以保持其持久性。关于您收到的 npm 错误,正如 jordanm 提到的,您当前目录中没有package.json
文件。You need to create an environment variable which points to the right directory. This should do the job:
or add it to your
.bashrc
file to keep it persistent. And regarding this npm error you get, as jordanm mentioned you don't havepackage.json
file in you current directory.您必须将路径存储在
.bashrc
文件中。您可以通过运行以下命令轻松完成。You have to store the path inside in your
.bashrc
file. You can do it easily by run following command.