安装create-react-app及webpack-dev-server时遇spdx-exceptions@^2.1.0版本匹配错误求助
Hey there, let's work through this frustrating version mismatch error you're hitting with both create-react-app and webpack-dev-server. The spdx-exceptions@^2.1.0 not found error typically happens when npm can't pull the required package version from your current registry, or there's a stale cache messing things up. Here are some tried-and-true fixes to get you back on track:
Clear your npm cache first
Stored cache files can sometimes hold outdated package info that causes version lookup failures. Run these commands to wipe and verify the cache:npm cache clean --force npm cache verifySwitch to the official npm registry
If you're using a third-party mirror (like some regional mirrors), it might not have synced thespdx-exceptions@2.1.0version yet. Switch back to the official registry with:npm config set registry https://registry.npmjs.org/Once your install works, you can switch back to your preferred mirror later if needed.
Manually install the required spdx-exceptions version
Force-install the exact version that's missing, then try your original install again:npm install spdx-exceptions@2.1.0 --save-dev # Now try installing your target package npx create-react-app my-app # Or for webpack-dev-server: npm install webpack-dev-server --save-devUpdate npm to the latest version
Older npm versions can have bugs in package resolution logic. Updating npm often resolves these kinds of version mismatch issues:npm install -g npm@latest
If none of the above work, try deleting your project's node_modules folder and package-lock.json (or yarn.lock if you use Yarn), then run npm install again to start fresh.
内容的提问来源于stack exchange,提问作者Wilson

