【问题标题】:How can i install yeoman command line tool on ubuntu 20.04.1 LTS?如何在 ubuntu 20.04.1 LTS 上安装 yeoman 命令行工具?
【发布时间】:2021-03-31 04:27:32
【问题描述】:

我尝试在 Ubuntu 20.04.1 LTS 中安装 yeoman 命令行工具,用于 ASP.NET Core Web 应用程序开发。输入后 npm install -g yo 在终端中,我遇到了错误。

错误描述如下。

npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN checkPermissions Missing write access to /usr/local/lib
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/shashankshekhar/.npm/_logs/2020-12-21T11_02_14_859Z-debug.log```

【问题讨论】:

  • sudo npm install -g yo ?

标签: asp.net-core ubuntu npm yeoman ubuntu-20.04


【解决方案1】:

全局模块安装时出现EACCES 错误的问题非常普遍,以至于npm 具有an entire web page dedicated to solving just this issue

由于您正在安装 yeoman,我想这是一台开发机器。在这种情况下,最好的办法是安装 node/npm 和像 nvm 这样的包管理器。

不想想做但人们经常建议做的一件事是使用sudo 运行npm 命令。人们推荐这个是因为它简单。但是,如果您这样做,您正在安装的任何依赖项的所有生命周期脚本(例如,postinstall)也将作为root 运行。这可能是大量以root 运行的不受信任的代码。

【讨论】:

    猜你喜欢
    • 2021-04-12
    • 2021-06-05
    • 1970-01-01
    • 2017-12-20
    • 1970-01-01
    • 2016-12-22
    • 2014-01-14
    • 2013-08-15
    • 1970-01-01
    相关资源
    最近更新 更多