41

I used generator-angular a few months ago to scaffold a project and the whole ecosystem (karma, Node versions, grunt packages) has moved on quite significantly. I keep running into problems running tests, building things, and so on.

I know I can use nvm to downgrade my Node version and install older packages, but that kind of sucks, especially when there are many developers on the team. I have used the generators for 10+ projects over the past few months so I'm very interested in a solution.

Is there a recommended upgrade path for when new versions of generators are released, apart from just regenerating the project and copying files across?

(Just to note: this isn't a problem with upgrading a Yeoman 0.9 project.)

Sindre Sorhus
  • 62,972
  • 39
  • 168
  • 232
mgnb
  • 2,803
  • 2
  • 16
  • 15
  • Have you tried running `npm update -g` for global packages and `npm update` for local packages in the project directories? – micjamking Aug 28 '13 at 06:56

1 Answers1

66

First make sure you have committed everything or have a backup, then just scaffold out over the project again. yo will ask you for each file if you want to overwrite. For those files you haven't edited, just say yes. For the other ones, type d for diff and see what's changed. Then manually do the changes, and run npm install & bower install to get the latest dependencies.

EDIT

As mentionned in comments by Markus Gattol :

yo <generator-name> now already run bower install & npm install i.e. no need to run them explicitly again – Markus Gattol

Rémi Becheras
  • 14,902
  • 14
  • 51
  • 81
Sindre Sorhus
  • 62,972
  • 39
  • 168
  • 232
  • 3
    Great answer! I didn't know it was smart enough to do the diff for me. Good to get authoritative answers from authoritative sources. – mgnb Aug 29 '13 at 04:31
  • 1
    `yo ` now already run `bower install & npm install` i.e. no need to run them explicitly again – evdama Dec 23 '14 at 08:58
  • @MarkusGattol don't know why but `bower install` always fails for me on all machines. I keep run it explicitly again. – ProblemsOfSumit Jul 31 '15 at 20:19
  • @Sumit this is because if bower isn't given root level permission all commands without a `--allow-root` will not run! – Gaurav Ramanan Aug 26 '16 at 08:05