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

node v17: Error loading tslib helper library #286

Closed
aladdin-add opened this issue Oct 20, 2021 · 14 comments · Fixed by #289, #290 or #326 · May be fixed by stoplightio/scripts#121
Closed

node v17: Error loading tslib helper library #286

aladdin-add opened this issue Oct 20, 2021 · 14 comments · Fixed by #289, #290 or #326 · May be fixed by stoplightio/scripts#121
Labels
scope: dependencies Issues or PRs about updating a dependency scope: upstream Issue in upstream dependency solution: workaround available There is a workaround available for this issue

Comments

@aladdin-add
Copy link

What happens and why it is wrong

Error loading `tslib` helper library.
/Users/weiran/repo/dian/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25177
    throw e;
    ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /Users/weiran/repo/dian/tsdx/node_modules/rollup-plugin-typescript2/node_modules/tslib/package.json

Environment

Versions
  Node: 17.0.0
  OS: macOS 12.0
  yarn: 3.0.2

   rollup: ^2.57.0 => 2.58.0 
    rollup-plugin-typescript2: ^0.30.0 => 0.30.0 
    typescript: ^4.4.3 => 4.4.4

rollup.config.js

`rollup.config.js`:

tsconfig.json

`tsconfig.json`:

package.json

`package.json`:

plugin output with verbosity 3

plugin output with verbosity 3:
@aladdin-add
Copy link
Author

this is from weiran-zsd/dts-cli#78.

@yoeunes
Copy link

yoeunes commented Oct 21, 2021

Hello @aladdin-add did you find any solution for this error ? I got it also with node 17

  Node: v17.0.1
  npm: 8.1.0
  OS: Ubuntu
  rollup: 2.58.0
 rollup-plugin-typescript2: 0.30.0

@aladdin-add
Copy link
Author

  1. just down to node < 17
  2. yarn resolutions:
"resolutions":{
  "tslib": "2.3.1"
}

@yoeunes

This comment was marked as resolved.

bluelovers added a commit to bluelovers/ws-yarn-workspaces that referenced this issue Nov 3, 2021
bluelovers added a commit to bluelovers/rollup-plugin-typescript2 that referenced this issue Nov 3, 2021
@xiCO2k

This comment was marked as spam.

@bluelovers
Copy link
Contributor

Checking in on this, any updates?

i think my pr can fix this

bluelovers added a commit to bluelovers/rollup-plugin-typescript2 that referenced this issue Nov 3, 2021
@bluelovers
Copy link
Contributor

can try this before merge apply

"rollup-plugin-typescript2": "bluelovers/rollup-plugin-typescript2#pr/node-v17-tslib-002",

ezolenko added a commit that referenced this issue Nov 3, 2021
@ezolenko
Copy link
Owner

ezolenko commented Nov 4, 2021

@bluelovers I'm having trouble building with node 17 (unrelated to your PR), because something breaks semver either at runtime (before upgrading commonjs plugin) or at build time, so I had to disable version check. Do you see those problems at all?

See this commit, which is basically your PR but with any changes needed to upgrade: cb2621f

I used normal resolve (stole it from rollup-plugin-typescript):

import resolve from "resolve";
const tslibPath = resolve.sync("tslib/tslib.es6.js");

Is your approach with @yarn-tool/resolve-package significantly better?

@bluelovers
Copy link
Contributor

bluelovers commented Nov 4, 2021

u need build at node.js 16, and disable version test before publish new version once

after this, enable ur version test will work

@aladdin-add
Copy link
Author

a workaround: if you are using docker, you can change the node:latest => node:lts(or node:16/14) to avoid the error.

@bluelovers
Copy link
Contributor

Is your approach with "@yarn-tool/resolve-package" significantly better?

@ezolenko u can see source code for watch what i do make it work on node.js 17

https://github.com/bluelovers/ws-yarn-workspaces/blob/e57f6acafbe7c00c43593823a5d16ada08aeb920/packages/%40yarn-tool/resolve-package/index.ts#L13

@ezolenko
Copy link
Owner

ezolenko commented Nov 17, 2021

@bluelovers released in 0.31.0, thanks for the PR

@aladdin-add
Copy link
Author

confirmed it has been fixed in v0.31.0. 🎉

and seems also fixed #267?

Gusted pushed a commit to darkreader/darkreader that referenced this issue Nov 25, 2021
- Fixes compiling the master on node v17.0+
- See ezolenko/rollup-plugin-typescript2#286
Gusted pushed a commit to darkreader/darkreader that referenced this issue Nov 25, 2021
- Fixes compiling the master on node v17.0+
- See ezolenko/rollup-plugin-typescript2#286
geekrainy added a commit to geekrainy/ali-react-table that referenced this issue Dec 21, 2021
@agilgur5 agilgur5 linked a pull request Apr 23, 2022 that will close this issue
@agilgur5 agilgur5 added solution: workaround available There is a workaround available for this issue scope: dependencies Issues or PRs about updating a dependency labels Apr 23, 2022
@agilgur5 agilgur5 linked a pull request May 6, 2022 that will close this issue
@agilgur5
Copy link
Collaborator

agilgur5 commented May 7, 2022

This seems to have been fixed upstream in tslib 2.4.0's package.json since microsoft/tslib#135 was recently merged and released. Basically the root cause is that the old way of doing * package exports was deprecated in Node 16 (c.f. #267), then removed in Node 17... but the new way didn't work on older Node versions so there were some compatibility issues to work through (now tslib uses both the old and new ways).

Is your approach with @yarn-tool/resolve-package significantly better?

So if we upgrade tslib to ^2.4.0 we should be able to move back to the old method using require.resolve and drop the additional dep of @yarn-tool/resolve-package.

Also, to workaround prior to 2.4.0 without an additional dep, we could have also resolved to absolute paths, as package exports do not prevent importing internals via absolute paths (exports are a "weak" encapsulation).

EDIT: see my tslib upgrade PR in #326

@agilgur5 agilgur5 added the scope: upstream Issue in upstream dependency label May 7, 2022
johntron added a commit to johntron/screeps-typescript-starter that referenced this issue May 8, 2022
Running `npm run push-main` gives this with nodejs 17:

> Package subpath './package.json' is not defined by "exports" in /home/wouldntyouliketoknow/node_modules/tslib/package.json

This change incorporates [the fix](ezolenko/rollup-plugin-typescript2#286) from rollup-plugin-typescript2 v0.31.0.
qnstie added a commit to evidenceprime/react-flow that referenced this issue Jun 14, 2022
pyrodogg pushed a commit to screepers/screeps-typescript-starter that referenced this issue Feb 11, 2023
Running `npm run push-main` gives this with nodejs 17:

> Package subpath './package.json' is not defined by "exports" in /home/wouldntyouliketoknow/node_modules/tslib/package.json

This change incorporates [the fix](ezolenko/rollup-plugin-typescript2#286) from rollup-plugin-typescript2 v0.31.0.
JiangWeixian added a commit to neo-hack/dayjs-plugin-template that referenced this issue Sep 3, 2023
JiangWeixian added a commit to neo-hack/dayjs-plugin-template that referenced this issue Sep 3, 2023
* 🐛  load tslib failed on node18

ezolenko/rollup-plugin-typescript2#286

Closes #2

* 💚  pnpm@7 and pnpm cache

* 📝  repo url

* 💚  remove node14 & node12 support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: dependencies Issues or PRs about updating a dependency scope: upstream Issue in upstream dependency solution: workaround available There is a workaround available for this issue
Projects
None yet
6 participants