10

I'm trying to set up yo to use the angular generator for a project. I am following the steps detailled here: http://yeoman.io/learning/index.html

I already have Node.js and NPM installed.

But when I use the command:

sudo npm install -g yo bower grunt-cli

It fails and I get this error:

> spawn-sync@1.0.11 postinstall /usr/lib/node_modules/yo/node_modules/cross-spawn/node_modules/spawn-sync
> node postinstall


fs.js:439
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: EACCES, permission denied '/usr/lib/node_modules/yo/node_modules/cross-spawn/node_modules/spawn-sync/package.json'
    at Object.fs.openSync (fs.js:439:18)
    at Object.fs.writeFileSync (fs.js:978:15)
    at Object.<anonymous> (/usr/lib/node_modules/yo/node_modules/cross-spawn/node_modules/spawn-sync/postinstall.js:20:6)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:935:3
npm ERR! Linux 3.13.0-24-generic
npm ERR! argv "node" "/usr/bin/npm" "install" "-g" "yo"
npm ERR! node v0.10.37
npm ERR! npm  v2.11.0
npm ERR! code ELIFECYCLE

npm ERR! spawn-sync@1.0.11 postinstall: `node postinstall`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the spawn-sync@1.0.11 postinstall script 'node postinstall'.
npm ERR! This is most likely a problem with the spawn-sync package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node postinstall
npm ERR! You can get their info via:
npm ERR!     npm owner ls spawn-sync
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vincent/npm-debug.log

I tried to use chmod 777 on /usr/lib/node_modules but it doesn't seem to work better.

I can install Bower and Grunt, it worked, but when I try to install Yo, it fails everytime...

I have no idea what to do as everything I tried using chmod or chown didn't work.

Thanks for your help guys! :)

Vincent Montalieu
  • 333
  • 2
  • 4
  • 10

5 Answers5

15

I worked around the issue by using:

sudo npm install -g yo --unsafe-perm

Use of --unsafe-perm suggested by nyakto in this bug report.

Edit - realised that this is the URL posted by @Stephan in his answer.

I don't know the specifics about --unsafe-perm - I can only state that it allowed me to install yo without errors I experienced that were very similar / identical to OP.

Trevor
  • 10,903
  • 5
  • 61
  • 84
  • From what I understand using sudo here is not a good idea, see [this answer](http://stackoverflow.com/a/24404451/967168) for a better solution – Felix Eve Nov 04 '15 at 02:40
9

The comment in the github repo fixed my issue. Basically just needed to update node version. Listing out the steps for future reference:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable
node -v

Cheers

Roy M J
  • 6,926
  • 7
  • 51
  • 78
1

Have a look at this bug report: https://github.com/ForbesLindesay/spawn-sync/issues/11

Stephan
  • 11
  • 1
0

I had the same issue . Apparently a common isse with yeoman. doing the following solved my issue try deleting all files in the /Users/yourusername/.config/configstore/ directory and then run the yo command as usual.

Malik
  • 3,520
  • 7
  • 29
  • 42
  • Thanks for the reply but I can't find this path. I'm on Linux, isn't it a Windows path you are giving me? – Vincent Montalieu Jun 01 '15 at 10:35
  • oh yes this is a windows path . if you are using linux env. look for a folder name **.config** in your home directory . it is hidden so press ctrl+H to show the folders . you should find a folder named **configstore** inside that . clean the folder and try runnning `yo` again – Malik Jun 01 '15 at 10:44
  • I tried that but I still get the same error. Inside the folder **configstore**, there were 3 files but all related to Bower which I successfully installed. So I guess that deleting those files didn't do anything about installing Yo. – Vincent Montalieu Jun 01 '15 at 15:21
0

I had same issue too,under linuxmint 17. Cause I use nodejs 0.10,and I upgrade npm to 2.X.

Try to reinstall nodejs and select the correct version https://github.com/nodesource/distributions

Good luck!

Partoo
  • 11
  • 3