我正在关注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)
我哪里出错了?
答案 0 :(得分:1)
我认为你没有做错什么看起来像是自耕农的依赖打破了自耕农。这是依赖于yeoman的环境,这个问题已经打开:https://github.com/yeoman/environment/issues/97复制粘贴下面的问题:
运行yo时,会发生以下错误:错误:EACCES: 许可被拒绝,scandir'/ usr / sbin / authserver(MacOS / High Sierra)
罪魁祸首在这里:
// Adds support for generator resolving when yeoman-generator has been linked if (process.argv[1]) { paths.push(path.join(path.dirname(process.argv[1]), '../..')); }
在getNpmPaths()中。我的哟在/ usr / local / bin / yo,这就加了 整个/ usr目录到搜索路径=> globby.sync里面 如果某些目录不是用户,resolver.findsGeneratorIn将抛出 可读的。 这样的事情解决了这个问题:
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
为了最大限度地减少权限错误的可能性,您可以将npm配置为 使用不同的目录。在这个例子中,它将是一个隐藏的 您的主文件夹上的目录。
在开始之前备份计算机。
为全局安装创建一个目录:
mkdir ~/.npm-global
配置npm以使用新目录路径:
npm config set prefix '~/.npm-global'
打开或创建〜/ .profile文件并添加以下行:
export PATH=~/.npm-global/bin:$PATH
返回命令行,更新系统变量:
source ~/.profile
测试:在不使用sudo的情况下全局下载软件包。
npm install -g jshint
代替步骤2-4,您可以使用相应的ENV变量(例如,如果您不想修改〜/ .profile):
NPM_CONFIG_PREFIX=~/.npm-global