I was following this tutorial and installed Yeoman and the Azure's generator.
So, when I did: sudo yo azuresfcontainer
, it gives me the following error:
/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)
Where did I go wrong?
I don't think you did anything wrong it looks like a dependency of yeoman broke yeoman. It is the yeoman-environment dependency and this issue has been opened: https://github.com/yeoman/environment/issues/97 Copy pasting the issue below:
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); }
I was able to workaround this by installing global packages to a different folder. 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