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

Open
ahasall opened this issue Apr 30, 2018 · 9 comments
Open
Assignees
Labels
bug

Comments

@ahasall
Copy link

@ahasall 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

@ahasall
Copy link
Author

@ahasall 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

@axe312ger axe312ger commented Apr 30, 2018

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

@axe312ger axe312ger closed this Apr 30, 2018
@ahasall
Copy link
Author

@ahasall 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

@axe312ger axe312ger commented Jul 23, 2018

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 ahasall commented Jul 23, 2018

Thank you very much.

@OliverAssad
Copy link

@OliverAssad 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

@eatarandom eatarandom commented Jan 30, 2020

@OliverAssad What was your solve here?

@larrybotha
Copy link

@larrybotha larrybotha commented Aug 17, 2020

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

  import {createClient} from 'contentful/dist/contentful.browser';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants