Error: EACCES, permission denied in command #yo angular

cnelkit792 picture cnelkit792 · Sep 20, 2014 · Viewed 11.1k times · Source

I come yeoman and angular begun to use that command but I threw this error, which I can do?

#yo angular

/usr/lib/node_modules/yo/node_modules/update-notifier/node_modules/configstore/node_modules/graceful-fs/polyfills.js:8
    cwd = origCwd.call(process)
                  ^
Error: EACCES, permission denied
    at process.cwd (/usr/lib/node_modules/yo/node_modules/update-notifier/node_modules/configstore/node_modules/graceful-fs/polyfills.js:8:19)
    at process.cwd (/usr/lib/node_modules/yo/node_modules/insight/node_modules/configstore/node_modules/graceful-fs/polyfills.js:8:19)
    at process.cwd (/usr/lib/node_modules/yo/node_modules/yeoman-generator/node_modules/download/node_modules/decompress/node_modules/decompress-tar/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/polyfills.js:8:19)
    at process.cwd (/usr/lib/node_modules/yo/node_modules/yeoman-generator/node_modules/download/node_modules/decompress/node_modules/decompress-tarbz2/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/polyfills.js:8:19)
    at process.cwd (/usr/lib/node_modules/yo/node_modules/yeoman-generator/node_modules/download/node_modules/decompress/node_modules/decompress-targz/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/polyfills.js:8:19)
    at process.cwd (/usr/lib/node_modules/yo/node_modules/yeoman-generator/node_modules/download/node_modules/decompress/node_modules/decompress-unzip/node_modules/temp-write/node_modules/graceful-fs/polyfills.js:8:19)
    at process.cwd (/usr/lib/node_modules/yo/node_modules/yeoman-generator/node_modules/glob/node_modules/graceful-fs/polyfills.js:8:19)
    at new Environment (/usr/lib/node_modules/yo/node_modules/yeoman-generator/lib/env/index.js:45:42)
    at createEnv (/usr/lib/node_modules/yo/node_modules/yeoman-generator/index.js:38:10)
    at init (/usr/lib/node_modules/yo/cli.js:71:40)

Answer

Adlen Afane picture Adlen Afane · Oct 6, 2014

Prefix your command with sudo will fix your problem but it is just a quick workaround. Another workaround would be to set the permission of this directory to your user. For instance

sudo chown $YOUR_USER -R /usr/lib/node_modules

But the best way would be to follow the great advice on the following gist