Last week I upgraded the dependencies of a ReactJS project by using yarn upgrade-interactive
(yarn version: 3.2.1
).
After the upgrade I faced the following error in multiple files:
Cannot find module ...
Since the error message did not directly indicate the cause of the error, I had to do some research, which led me to the following result.
To fix the error(s), I executed the statements below in Visual Studio Code terminal of the corresponding project:
# remove the shared cache files
yarn cache clean
# install packages
yarn install
yarn dlx @yarnpkg/sdks vscode
# set yarn to newest version (3.x.x)
yarn set version berry
# !!! delete yarn.lock
# install packages
yarn install
Bonus
To find dependencies (including transitive dependencies) with known vulnerabilities, execute the following command.
yarn npm audit --recursive
If a vulnerability is found in a transitive dependency, you can update it as described here.
Leave a Reply