根据npm错误提示,问题是 React 18.0.0 被引入至CRA导致依赖冲突,手动改 package.json
降级到 React 17 还是会挂。具体什么问题已经无法排查出来了,一个CRA包了太多东西。
然后拉到 GitHub 仓库里最早的一版课程代码全部拉到本地 npm i
还是依赖出错。因为没有 package-lock.json
所以肯定版本号没固定,然后我用 yarn install
,能无错误安装了,但是 yarn start
还是报错。
下面是 yarn start 的报错信息:
node:internal/modules/cjs/loader:488
throw e;
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in /Users/.../jira-clone/node_modules/postcss-safe-parser/node_modules/postcss/package.json
at new NodeError (node:internal/errors:372:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:448:9)
at packageExportsResolve (node:internal/modules/esm/resolve:727:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/.../jira-clone/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
希望老师能尽快更新一下环境搭建的教程,否则根本没法学,已经折腾了一整天了。
解锁 React17 高阶用法,轻松应对大型复杂长周期项目
了解课程