create-react-app 创建新应用时,由于postcss版本问题,node 17出现了故障,

piv4azn7  于 3个月前  发布在  React
关注(0)|答案(3)|浏览(46)

描述bug

在用create-react-app创建了一个新的应用后,它无法启动:

yarn run v1.22.17
$ react-scripts 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 /home/pawel/dev/baz/node_modules/postcss-safe-parser/node_modules/postcss/package.json
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:429:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:683: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> (/home/pawel/dev/baz/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Node.js v17.1.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

似乎create-react-app使用的postcss-safe-parser版本与node 17不兼容: postcss/postcss-safe-parser#29

重现步骤

  1. 安装node 17
  2. create-react-app foo创建一个新的应用
  3. cd foo
  4. yarn startnpm start
  5. 应用无法启动,上述错误是原因
3pvhb19x

3pvhb19x1#

这不是修复此错误的方法,但在问题修复之前,如果有人需要解决方法 - https://stackoverflow.com/a/69698758/1946418

相关问题