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

ERROR in ./node_modules/contentful-sdk-core/dist/es-modules/get-user-agent.js #58

Closed
ahasall opened this issue Apr 30, 2018 · 11 comments
Closed
Assignees
Labels

Comments

@ahasall
Copy link

ahasall commented Apr 30, 2018

Hello,

I installed the latest Contentful SDK.

When I build my application I have the following error:
ERROR in ./node_modules/contentful-sdk-core/dist/es-modules/get-user-agent.js

When I check the source code of get-user-agent.js if find this:

import { platform, release } from 'os';

Knowing that I build for the web, and that the 'os' module if for Node.js apps, I suppose that this import is the reason for the error.

Do you have any idea about this issue ?

Thanks

@axe312ger
Copy link
Contributor

@ahasall
Copy link
Author

ahasall commented Apr 30, 2018

Okay, thank you. I will create the issue on the Angular CLI repository because I don't have direct access to the Webpack config.

@axe312ger
Copy link
Contributor

Argh damn, yeah this is nasty :/ Good luck!

@ahasall
Copy link
Author

ahasall commented Jul 19, 2018

Hello @axe312ger,
It's me again :)

The Angular CLI team believes that libraries that are meant to run inside the browser are not supposed to use Node API.

I am afraid that they are not willing to provide to override that Webpack config.

Do you plan to add a version of your library that doesn't use those APIs ?

Thanks,
Amadou

@axe312ger
Copy link
Contributor

Alright, we will have a look how to avoid importing these node core modules on top level.

@axe312ger axe312ger reopened this Jul 23, 2018
@axe312ger axe312ger added the bug label Jul 23, 2018
@axe312ger axe312ger self-assigned this Jul 23, 2018
@ahasall
Copy link
Author

ahasall commented Jul 23, 2018

Thank you very much.

@OliverAssad
Copy link

OliverAssad commented Jul 4, 2019

I have ran into the same problem, this time using rollup in a svelte/sapper app.

✗ client
node_modules/contentful-sdk-core/dist/es-modules/get-user-agent.js (1:9)
'platform' is not exported by node_modules/rollup-plugin-node-resolve/src/empty.js
1: import { platform, release } from 'os';
            ^
2: import { isNode, getNodeVersion } from './utils';

rollup offers different plugins to resolve the issue, one of them is rollup-plugin-commonjs with named imports here . However this didn't work either.

Just wanted to say this is not a Webpack problem ..

@eatarandom
Copy link

@OliverAssad What was your solve here?

@larrybotha
Copy link

@eatarandom and @ahasall importing the browser module directly appears to work:

  import {createClient} from 'contentful/dist/contentful.browser';

@adamszeptycki
Copy link

@larrybotha thanks for that - works for now.
But would be great to have a real solution to this problem.

@marcolink
Copy link
Member

We addressed this issue with this [PR](#198 which got released in version v6.8.5.
The updated dependency is available from contentful.js@8.5.3

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

No branches or pull requests

7 participants