无法使用sudo运行npm命令

时间:2019-06-07 16:16:03

标签: npm environment-variables sudo nvm

我最近通过 npm 安装了 balena-cli 软件包(该软件包本身已使用 nvm 安装),在访问时可以正常工作来自我的默认用户。

但是,每当我尝试使用sudo访问npm,nvm或balena-cli时,它们都会打印以下错误

sudo chown

我尝试对全部3种设备使用<input type='text' value='blanchedalmond' name='triggerSet' id='triggerSet' /> <input type='text' placeholder='Enter A Color' id='enterAColor' /> <button id='btnEnterAColor'>Trigger Set</button> <script> $("#triggerSet").spectrum(); // Show the original input to demonstrate the value changing when calling `set` $("#triggerSet").show(); $("#btnEnterAColor").click(function() { $("#triggerSet").spectrum("set", $("#enterAColor").val()); }); </script> ,但现在仍然可用。

基本上,不能使用root来访问与Node相关的任何功能。 关于如何解决此问题的任何建议,也许可以通过使用环境变量来解决?

2 个答案:

答案 0 :(得分:0)

作为一个停顿点,我发现在切换到root 之后运行相同的命令可以与以下命令配合使用;

$ sudo -s

但是,由于这是一个停顿间隙,所以找到一种方法来运行相同的命令而不用在root用户之间来回切换非常好。

答案 1 :(得分:0)

基本上一次检查一下您是否已正确刷新Balena映像,然后检查网络权限并使用root登录到Balena,并使用su(而不是sudo)运行命令,则可能会清除您的问题。

相关问题