gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 05:49:04 24 4
gpt4 key购买 nike

我正在关注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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com