Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builds Don't Work with Node v17 Release #29

Closed
ralfisalhon opened this issue Oct 20, 2021 · 23 comments
Closed

Builds Don't Work with Node v17 Release #29

ralfisalhon opened this issue Oct 20, 2021 · 23 comments

Comments

@ralfisalhon
Copy link

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:

(node:3713) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /tmp/workspace/node_modules/postcss-safe-parser/node_modules/postcss/package.json.
Update this package.json to use a subpath pattern like "./*".
@ai
Copy link
Member

ai commented Oct 20, 2021

Try to update postcss. We fixed exports in postcss a few releases ago. Maybe the issue happened because of the old postcss.

@ralfisalhon
Copy link
Author

This version of postcss is a react-scripts dependency and not something we should manually update. I'm worried that other people will run into this issue unintentionally

@ai
Copy link
Member

ai commented Oct 20, 2021

Do you use postcss 7?

Can you show PostCSS versions from npm ls?

@RedHairring
Copy link

Bump, having the same issue and our website is down in production till there is a fix

@kanto2113
Copy link

Same issue here. Started about 2 hours ago when I tried to re-deploy my react website.

@ai
Copy link
Member

ai commented Oct 20, 2021

@RedHairring @kanto2113 what PostCSS version do you use? Check npm ls.

@kanto2113
Copy link

kanto2113 commented Oct 20, 2021

@ai npm ls doesn't list PostCSS. The react-scripts npm module has the following as dependencies.

"postcss-flexbugs-fixes": "4.2.1",
"postcss-loader": "3.0.0",
"postcss-normalize": "8.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "5.0.2" 

@ai
Copy link
Member

ai commented Oct 20, 2021

@kanto2113 call npm ls in the terminal inside your project. Put the output to https://gist.github.com and post the result here.

@kanto2113
Copy link

@ai
Copy link
Member

ai commented Oct 20, 2021

@kanto2113 seems like you are using PostCSS 7, which is not supported anymore because PostCSS 8 was released around 2 years ago.

Create React App has system problem with maintaince. As I know, PostCSS 8 migration was still not release.

I do not really like to fixing my old releases because of CRA maintainers (it is not fair that I am working for them). But if somebody sends a well-tested PR to v7 branch, I can release it. Just start from reading the docs, it is easy to break system for other environments (for instance, * can’t be used, we need to manually listed all possible files as we did in main).

@dantman
Copy link

dantman commented Oct 23, 2021

I do not really like to fixing my old releases because of CRA maintainers (it is not fair that I am working for them). But if somebody sends a well-tested PR to v7 branch, I can release it.

Unfortunately there's no point to that. react-scripts@4.0.3 has postcss-safe-parser pinned to 5.0.2 exactly. So even if make a new patch release it won't be installed.

It looks like CRA has already updated PostCSS to v8 and also removed postcss-safe-parser as part of the WebPack 5 update. However of course they haven't released any of the work done on CRA since Feb so we're stuck with this issue.

@heymike777
Copy link

Is there any fix for this?

@ai
Copy link
Member

ai commented Oct 23, 2021

@Timashov nope. Only eject the configs and avoid using CRA in the future.

@experimatt
Copy link

experimatt commented Oct 24, 2021

Ugh, I'm in the same boat. npm ls output: https://gist.github.com/experimatt/56661550572ccfcfcf03ebc3c7dfc976

[ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in node_modules/postcss-safe-parser/node_modules/postcss/package.json

I do not really like to fixing my old releases because of CRA maintainers (it is not fair that I am working for them).

@ai: you have my sympathy. I really appreciate all the time, energy, and hard work you put into maintaining this and other packages. I'm donating to support your work now: https://opencollective.com/postcss/contribute

@ai
Copy link
Member

ai commented Oct 24, 2021

@dantman

Unfortunately there's no point to that. react-scripts@4.0.3 has postcss-safe-parser pinned to 5.0.2 exactly. So even if make a new patch release it won't be installed.

The fix can be applied to postcss 7.x. Does CRA pinned postcss?

@dantman
Copy link

dantman commented Oct 24, 2021

The fix can be applied to postcss 7.x. Does CRA pinned postcss?

Technically CRA does not pin PostCSS. They pin the following:

    "postcss-flexbugs-fixes": "4.2.1",
    "postcss-loader": "3.0.0",
    "postcss-normalize": "8.0.1",
    "postcss-preset-env": "6.7.0",
    "postcss-safe-parser": "5.0.2",

And PostCSS comes in indirectly:

+-- postcss-flexbugs-fixes@4.2.1
| `-- postcss@7.0.39
+-- postcss-loader@3.0.0
| `-- postcss@7.0.39 deduped
+-- postcss-normalize@8.0.1
| +-- postcss-browser-comments@3.0.0
| | `-- postcss@7.0.39 deduped
| `-- postcss@7.0.39 deduped
+-- postcss-preset-env@6.7.0
| +-- (a bunch of dependencies, each with)
| | `-- postcss@7.0.39 deduped
| `-- postcss@7.0.39 deduped
`-- postcss-safe-parser@5.0.2
  `-- postcss@8.3.11

And postcss-preset-env does appear to use postcss: ^7.0.17 so fixing it there could work.

Though I will note that postcss-safe-parser@5.0.2 uses postcss: ^8.1.0. For a number of pre-existing projects this means our package-lock actually has a postcss before 8.2.11 (when the bug was fixed). And I don't know if any way of telling node to update a deep package list this, short of deleting the entire lockfile. Given node's resolution algorithm I suspect this may be the real issue. And even if the 7.x packages turn out also be an issue, for most of us the issue will remain even after a normal npm package install and update due to our lockfiles.

dodonki1223 added a commit to dodonki1223/clone-netflix that referenced this issue Nov 30, 2021
Node のバージョンが v16.13.0 だと以下のようなエラーが出てビルドに失敗するため、一旦 Node のバージョンを下げることで対応する

```
(node:3713) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /tmp/workspace/node_modules/postcss-safe-parser/node_modules/postcss/package.json.
Update this package.json to use a subpath pattern like "./*".
```

react-scripts のバージョン(4.0.3)が上がるまで待つしかない……。
詳しくは以下のページを確認してください
- postcss/postcss-safe-parser#29
- facebook/create-react-app#11565
dodonki1223 added a commit to dodonki1223/clone-netflix that referenced this issue Nov 30, 2021
Node のバージョンが v16.13.0 だと以下のようなエラーが出てビルドに失敗するため、一旦 Node のバージョンを下げることで対応する

```
(node:3713) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /tmp/workspace/node_modules/postcss-safe-parser/node_modules/postcss/package.json.
Update this package.json to use a subpath pattern like "./*".
```

react-scripts のバージョン(4.0.3)が上がるまで待つしかない……。詳しくは以下のページを確認してください

- postcss/postcss-safe-parser#29
- facebook/create-react-app#11565
@cojack
Copy link

cojack commented Dec 13, 2021

Is there any fix for this?

yes, @Timashov downgrade your node version to 16

@spykard
Copy link

spykard commented Apr 4, 2022

Still occuring

@artginzburg
Copy link

Same issue here. Currently bypassing it by downgrading to Node LTS (16).

The thing is, the project I'm talking about cannot even be safely updated to a newer version, because it was ejected from CRA.

New apps built with CRA work fine on Node 18 though.

@byteshiva
Copy link

Failing for Node v17.5.0

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in /home/xyz/sample/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:705: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/xyz/sample/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

@byteshiva
Copy link

Failing for Node v17.5.0

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in /home/xyz/sample/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:705: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/xyz/sample/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

The below fix worked for me.

Update postcss on v17.5.0

npm install  postcss   

@cosmicknox
Copy link

npm install postcss

this worked for me thanks

@xanderjames1910
Copy link

I had the same issue and as many of you say, it's a problem with react-scripts and postcss because of React version.

I fixed it in my React app by removing node_modules folder and yarn.lock file, then I updated my React version and also my react-dom dependency with:

yarn add react@latest react-dom@latest

Then I ran yarn so my node_modules get installed again, which fixed my issue.

I hope this helps some of you.

This worked for me because it's a small React App. You should probably verify if other dependencies are compatible with the latest React version (now 18.2.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests