简体   繁体   中英

How can I solve web vital error when I try yarn start?

I created a React app by Yarn, but when I tried to start I got this error below. This is happening with all my applications.

yarn start
yarn run v1.22.17
warning ../package.json: No license field
$ 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/barry/state/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:416:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:669: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/barry/state/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

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

I've tried npm i web-vitals --save-dev and yarn add -D web-vitals but it does not work anymore.

I've tried yarn add -g web-vitals too.

There is an ongoing issue related to Create React App and builds with Node v17.

See create-react-app #11565

Try node --version to see which version of node you are using. If it is a v17+, then you are likely hitting this bug.

To get around the issue, you can use a version of Node < v17, delete node_modules folder and the lockfile of whichever system you're using — yarn.lock or package-lock.json — then reinstall dependencies.

try:

yarn upgrade

fixed the bug for me, and React App started working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM