create-react-app: Builds Don't Work with PostCSS After Update
In Node v17:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in /tmp/workspace/node_modules/postcss-safe-parser/node_modules/postcss/package.json
In earlier versions of Node, this was just a deprecation warning:
Update this package.json to use a subpath pattern like "./*".
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 56
- Comments: 44
Commits related to this issue
- fix(web): 🐛 use node 16 until CRA fixed ref https://github.com/facebook/create-react-app/issues/11565 — committed to collinbarrett/FilterLists by collinbarrett 3 years ago
- fix: rebuild deps See https://github.com/facebook/create-react-app/issues/11565 Solution was `rm -rf node_modules; rm yarn.lock; yarn` — committed to dwmorrin/material-calendar by dwmorrin 3 years ago
- Downgraded frontend to Node 16 to fix bug in modules ... ... https://github.com/facebook/create-react-app/issues/11565 — committed to briandamaged/relearning-react by briandamaged 3 years ago
- :bug: react-scripts に依存している postcss に既知のバグがあり動かなくなるので Node のバージョンを下げる Node のバージョンが v16.13.0 だと以下のようなエラーが出てビルドに失敗するため、一旦 Node のバージョンを下げることで対応する ``` (node:3713) [DEP0148] DeprecationWarning: Use of de... — committed to dodonki1223/clone-netflix by dodonki1223 3 years ago
- :bug: react-scripts に依存している postcss に既知のバグがあり動かなくなるので Node のバージョンを下げる Node のバージョンが v16.13.0 だと以下のようなエラーが出てビルドに失敗するため、一旦 Node のバージョンを下げることで対応する ``` (node:3713) [DEP0148] DeprecationWarning: Use of de... — committed to dodonki1223/clone-netflix by dodonki1223 3 years ago
- rebuild yarn.lock with node 17 Workaround for the problem with node 17: https://github.com/facebook/create-react-app/issues/11565 — committed to sledilnik/zdravniki by stefanb 3 years ago
- removed error of postcss yarn add lts[https://github.com/facebook/create-react-app/issues/11565#issuecomment-1108835726] — committed to sath26/oldskool-html-bootstrap by sath26 2 years ago
@timashov, rolling back to Node 16.8.0 helped me.
High chance it will break the application, i recommend you never do that to your project
Nuked my node modules and yarn.lock and ran
yarn install
and it worked. Using cra typescript template.Just remove yarn.lock & node_modules & run
yarn
Why is this closed? I don’t see a fix… Only some pretty risky workarounds
Can we get a real fix and not downgrading Node version? Current LTS is now 18.13.0.
Package subpath ‘./lib/parser’ is not defined by “exports” in /home/node/app/node_modules/postcss/package.json I am getting an error like this today suddenly.
Having this issue, wiping out node_modules didn’t work, the only solution that’s worked for me is
nvm use 16.8.0
.why is this closed ? what’s the real fix ?
I was receiving Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./lib/parser’ is not defined by “exports” in …node_modules\next\node_modules\postcss\package.json
I have resolved it on node version 17.4.0 after I upgraded react, and nextjs using: npm install react@latest react-dom@latest npm install next@12
(https://nextjs.org/docs/upgrading)
npm audit fix --force also fixed this issue for me
@Senbonzakura1234 The application is already broken. I don’t understand why one would hesitate to do this on a fresh cra app ??
npm audit fix --force fixed this issue for me
I used these commands to deploy to production on Vercel. Simply insert it in the “Install Command” field. Rename your yarn.lock or package.lock files ending with -backup from github repo just incase of anything.
npm install next@12 && npm install react@latest react-dom@latest && npm i --package-lock-only && yarn install && npm audit fix --force
Upgrading should solve your issue: https://nextjs.org/docs/upgrading
I sort it by using nvm install --lts
on node
v17.0.1
. deletedyarn.lock
andnode_modules
then didyarn install
and worked for methis works for me
Ok so I actually got pass this issue but updating to postcss": “8.2.12”
My node was 17.0. Had to get LTS
nvm install lts
If you don’t have nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
source ~/.nvm/nvm.sh
yarn upgrade
worked for me.or you can use
nvm
with engines field in package.jsonI think the easy fix for this would be to go back a node version, so let’s say if you’re on 17.7, you want to go to 16.6 or anything lower than 17…
This problem occurred for me and I used Volta which helped me go back a node version really easily… After you’re done installing Volta, you can do this and enjoy your React App 😄
I did the same as people above, migrate back to node 16.8.0
The solution of removing yarn.lock and node_modules does not work for me. I get a large number of these errors, and Yarn fails:
This is related to postcss/postcss-safe-parser#29. Which is actually entirely CRA’s fault because
react-scripts@4.0.3
is using PostCSS 7 (obsolete) and an old version ofpostcss-safe-parser
.It looks like the work fixing this issue was already merged in July (PostCSS was updated to version without this Node 17 issue in #11121, and
postcss-safe-parser
was removed in #11201). However none of that has been released yet. All of that is being pushed to CRA v5, however I don’t see anything in the 5.0 milestone that should in any way block a CRA 5.0 release.