azure - 即使使用 sudo,Yeoman 也会给出权限错误

标签 azure yeoman azure-service-fabric yo

我正在关注this tutorial并安装了 Yeoman 和 Azure 的生成器。

所以,当我这样做时:sudo yo azuresfcontainer,它给了我以下错误:

/usr/local/lib/node_modules/yo/node_modules/fast-glob/out/providers/reader-sync.js:45
            throw err;
            ^

Error: EACCES: permission denied, scandir '/usr/lib/ssl/private'
    at Object.fs.readdirSync (fs.js:875:3)
    at exports.readdir (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/sync/fs.js:18:20)
    at Object.safeCall [as safe] (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/call.js:24:8)
    at DirectoryReader.readNextDirectory (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/directory-reader.js:78:10)
    at Readable.DirectoryReader.stream._read (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/directory-reader.js:57:18)
    at Readable.read (_stream_readable.js:455:10)
    at readdirSync (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/sync/index.js:27:21)
    at Function.readdirSyncStat (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/index.js:34:10)
    at ReaderSync.dynamicApi (/usr/local/lib/node_modules/yo/node_modules/fast-glob/out/providers/reader-sync.js:61:24)
    at ReaderSync.api (/usr/local/lib/node_modules/yo/node_modules/fast-glob/out/providers/reader-sync.js:53:25)
Emitted 'error' event at:
    at DirectoryReader.emit (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/directory-reader.js:365:14)
    at call.safe (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/directory-reader.js:81:14)
    at onceWrapper (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/call.js:45:17)
    at onceWrapper (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/call.js:45:17)
    at exports.readdir (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/sync/fs.js:22:5)
    at Object.safeCall [as safe] (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/call.js:24:8)
    [... lines matching original stack trace ...]
    at readdirSync (/usr/local/lib/node_modules/yo/node_modules/@mrmlnc/readdir-enhanced/lib/sync/index.js:27:21)

我哪里出错了?

最佳答案

我不认为你做错了什么,看起来自耕农的依赖破坏了自耕农。这是 yeoman-environment 依赖项,此问题已打开:https://github.com/yeoman/environment/issues/97复制粘贴以下问题:

While running yo, the following error occurs: Error: EACCES: permission denied, scandir '/usr/sbin/authserver (MacOS / High Sierra)

Culprit is here:

  // Adds support for generator resolving when yeoman-generator has been linked
  if (process.argv[1]) {
        paths.push(path.join(path.dirname(process.argv[1]), '../..'));
  }

inside getNpmPaths(). My yo is at /usr/local/bin/yo, and this adds the whole /usr directory to the search path => globby.sync inside resolver.findsGeneratorIn will throw if some directories are not user readable.

Something like this fixes the issue:

try {
      modules = modules.concat(globby.sync(
        ['generator-*', '@*/generator-*'],
        {cwd: root, onlyFiles: false, absolute: true}
      ));
} catch(err) {
     debug( 'Could not access %s (%s)', root, err); 
}

我可以通过将全局包安装到不同的文件夹来解决这个问题。 https://docs.npmjs.com/getting-started/fixing-npm-permissions

To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, it will be a hidden directory on your home folder.

Back-up your computer before you start.

Make a directory for global installations:

mkdir ~/.npm-global 

Configure npm to use the new directory path:

npm config set prefix '~/.npm-global'

Open or create a ~/.profile file and add this line:

export PATH=~/.npm-global/bin:$PATH

Back on the command line, update your system variables:

source ~/.profile

Test: Download a package globally without using sudo.

npm install -g jshint

Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don't want to modify ~/.profile):

NPM_CONFIG_PREFIX=~/.npm-global

关于azure - 即使使用 sudo,Yeoman 也会给出权限错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50329264/

相关文章:

azure - 用户流 "Sign in v2"的 AD B2C forceChangePasswordNextLogin 不会启动密码重置并阻止成功登录

azure - 仅为我的 Web 应用程序配置 Azure SQL 数据库防火墙

node.js - 使用 npm 开关在 Windows 下运行 Yeoman Generator

javascript - 如何运行使用 yeoman 创建的 AngularJS 应用程序

azure - Bot Framework 的 web.config 文件中用于连接 Azure SQL Server 数据库的连接字符串

angularjs - 配置 Yeoman 以构建非根项目

azure-service-fabric - 如何重新启动 Service Fabric 规模集计算机

azure-service-fabric - Azure Service Fabric可靠参与者与可靠服务

powershell - 如何停止空闲的 Service Fabric 集群升级?

javascript - 使用 SAS key 直接从客户端上传到 Azure 存储