After upgrade gatsby
from 2.15.14 → 2.21.21
, running gatsby develop
throws strange exception.
ERROR
There was a problem loading the local develop command. Gatsby may not be installed. Perhaps you need to run "npm install"? Cannot find module './lib'
Error: Cannot find module './lib'
To find out the reason, I cost a bunch of time to upgrade all packages one by one. And the error occurred only after upgrade gatsby
.
The most strange thing is that even after downgrade gatsby
to the version before, the error didn’t disappear. I googled and searched the error report in gatsby’s github, but got nothing.
But finally I found that after downgrade gatsby
, if I delete node_modules
and re-install all things again. The system ran normally.
Yes! That’s the solution
After upgrade all packages including gatsby
, delete node_modules
and re-install all packages should solve the problem.
yarn upgrade --latest
rm -rf node_modules
yarn