You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装create-react-app及webpack-dev-server时遇spdx-exceptions@^2.1.0版本匹配错误求助

解决npm安装时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 verify
    
  • Switch to the official npm registry
    If you're using a third-party mirror (like some regional mirrors), it might not have synced the spdx-exceptions@2.1.0 version 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-dev
    
  • Update 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:42:00