安装web-component-tester遇@types/escodegen@^0.0.2 404错误求解决
Hey there, sorry to hear you're stuck on this 404 issue while trying to set up web-component-tester for your Polymer project. The root problem is that the specific version of @types/escodegen (^0.0.2) required by one of web-component-tester's dependencies has been removed from the npm registry. Here are a few reliable workarounds to get you up and running:
Option 1: Force a Valid Dependency Version with npm Overrides
npm lets you override dependency versions for any package in your project. Add this section to your package.json:
"overrides": { "@types/escodegen": "0.0.39" }
0.0.39 is the latest existing version of @types/escodegen (the package is now deprecated, so no newer versions exist). Then re-run your install command:
npm install web-component-tester --save
Option 2: Use Yarn with Resolutions
If you prefer Yarn over npm, you can use its resolutions feature to achieve the same result. Add this to your package.json:
"resolutions": { "@types/escodegen": "0.0.39" }
Then install web-component-tester with:
yarn add web-component-tester
Option 3: Manually Install the Valid Dependency First
You can pre-install the working version of @types/escodegen before adding web-component-tester, which will prevent npm from trying to fetch the missing version:
npm install @types/escodegen@0.0.39 --save-dev npm install web-component-tester --save
Bonus: Consider a Modern Alternative (Optional)
Keep in mind that web-component-tester hasn't been actively maintained in several years. If you're open to switching tools, @web/test-runner is a great modern alternative that supports Polymer components and has ongoing updates.
内容的提问来源于stack exchange,提问作者TronchDeYack

