Asked here in slack: https://gitter.im/canjs/canjs?at=5c36397357c6883f9b8af85a, the question is
Is there a way to simultaneously upgrade all npm libraries to a compatible version when moving to can4 from can3 ?
Unfortunately, there’s not an easy way of doing this. We’ve actually been talking about creating something to do this. For example: https://twitter.com/justinbmeyer/status/1080513028985110528
So the process is currently a manual one. The place to start is to look at the dependencies
of the package.json of the release you want to upgrade to. For example, here is 4.3.0:
Most likely, you don’t need all of those packages. You can probably start with the ones you need:
"can-component": "4.2.2",
"can-define": "2.4.0",
"can-debug": "1.3.0",
"can-route": "4.3.0",
"can-stache": "4.9.0",
"can-stache-route-helpers": "1.1.0",
Once that is done, I suggest adding ^
to get the latest 4.0
compatible versions of everything:
"can-component": "^4.2.2",
"can-define": "^2.4.0",
"can-debug": "^1.3.0",
"can-route": "^4.3.0",
"can-stache": "^4.9.0",
"can-stache-route-helpers": "^1.1.0",
IMPORTANT!!! package-lock.json
is your enemy while doing this. Make sure to delete it (and keep deleting it) or add a .npmrc
file with:
package-lock=false
Example: https://github.com/canjs/can-component/blob/master/.npmrc
Once your app works again, it’s fine to bring back a package-lock.json
. But anytime you change your packages, you should always:
- delete the package-lock
- delete
node_modules
- update your package.json
npm install