最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

[npm无法使用sudo运行

IT培训 admin 4浏览 0评论

[npm无法使用sudo运行

我在亚马逊EC2节点(弹性豆秆)上,如果运行npm,则会得到:

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    clean-install, clean-install-test, completion, config,
    create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
    edit, explore, get, help, help-search, hook, i, init,
    install, install-ci-test, install-test, it, link, list, ln,
    login, logout, ls, org, outdated, owner, pack, ping, prefix,
    profile, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, team, test, token, tst, un,
    uninstall, unpublish, unstar, up, update, v, version, view,
    whoami

npm <command> -h  quick help on <command>
npm -l            display full usage info
npm help <term>   search for help on <term>
npm help npm      involved overview

Specify configs in the ini-formatted file:
    /home/ec2-user/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

[email protected] /home/ec2-user/.nvm/versions/node/v12.11.1/lib/node_modules/npm

但是如果我运行sudo npm,我会得到:

sudo: npm: command not found

我需要使用sudo才能使脚本正常工作。

回答如下:

通常,当root用户在其shell设置中没有相应的二进制路径时,会发生这种情况。如果使用Bash,则可以编辑/etc/profile来设置为每个登录Shell执行的所有用户的环境设置。

[npm无法使用sudo运行

我在亚马逊EC2节点(弹性豆秆)上,如果运行npm,则会得到:

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    clean-install, clean-install-test, completion, config,
    create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
    edit, explore, get, help, help-search, hook, i, init,
    install, install-ci-test, install-test, it, link, list, ln,
    login, logout, ls, org, outdated, owner, pack, ping, prefix,
    profile, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, team, test, token, tst, un,
    uninstall, unpublish, unstar, up, update, v, version, view,
    whoami

npm <command> -h  quick help on <command>
npm -l            display full usage info
npm help <term>   search for help on <term>
npm help npm      involved overview

Specify configs in the ini-formatted file:
    /home/ec2-user/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

[email protected] /home/ec2-user/.nvm/versions/node/v12.11.1/lib/node_modules/npm

但是如果我运行sudo npm,我会得到:

sudo: npm: command not found

我需要使用sudo才能使脚本正常工作。

回答如下:

通常,当root用户在其shell设置中没有相应的二进制路径时,会发生这种情况。如果使用Bash,则可以编辑/etc/profile来设置为每个登录Shell执行的所有用户的环境设置。

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论