This discrepancy is likely because the package-lock.json
or previously cached modules contain versions that conflict with your intended updates or installations.
Cached Node Modules:
npm install
uses the existing node_modules
and package-lock.json
.package-lock.json
and your local environment, errors occur.Project Initialization Differences:
npm init playwright@latest
sets up a fresh project environment every time, automatically fetching and resolving the correct dependencies.package-lock.json
, ensuring a clean installation.Node Version Incompatibility:
npm init playwright@latest
even warns about the Node version incompatibility but still manages to work because it creates a fresh environment.First, clear the npm cache to ensure no remnants of old installations remain.
npm cache clean --force
Remove the node_modules
folder and package-lock.json
to get a clean slate.
rm -rf node_modules package-lock.json
If you're on Windows (PowerShell):
rm -r node_modules
rm package-lock.json
Run npm install
to reinstall the dependencies fresh.
npm install
If Rollup version issues persist, manually install the correct version:
npm install rollup@latest --save-dev
Or, if you need a specific version:
npm install [email protected] --save-dev
Check your Node version and upgrade it if necessary.
node -v
npm -v
If you find the Node version is outdated, upgrade it using NVM:
nvm install 20 # Or whichever version you'd prefer
nvm use 20
Then, reinstall npm:
npm install -g npm
As a last resort, recreate the project setup:
npm init playwright@latest -- --ct