contentful.js: Module not found: Error: Can't resolve 'os'
- Node Version: 8.11.1
- Npm Version: 5.6.0
- Platform: Mac OS 10.13.4
- Package Version: 5.1.3
I am using Contentful with Angular and have set up the service in my project following the instructions here. Everything worked perfectly with Angular 5.x, but I get the following error after upgrading to Angular 6:
ERROR in ./node_modules/contentful-sdk-core/dist/es-modules/get-user-agent.js
Module not found: Error: Can't resolve 'os' in '/Users/dbellizio/Dev/epri/epri-mcr-poc/node_modules/contentful-sdk-core/dist/es-modules'
My project is Angular CLI based, which as of version 6 now uses webpack 4 for the build process. Angular 5 uses webpack 3. So I’m wondering if that has something to do with it. The error occurs when running ng serve or any other Angular CLI build command.
For what it’s worth, I tried upgrading to version 6.1.0 of Contenful, but the error remains.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 20 (11 by maintainers)
I got this issue for a different library, but solved it by running
npm install --save os@bellizio yes
@Khaledgarbaya so just to clarify: the fix in version 6.1.1 means the workaround in tsconfig.json can be removed now?
Hey @briancodes we shipped a fix that should solve your problem, v6.1.1.
Hi @briancodes this definitely needs a deeper investigation. I will look into it soon
I am adding a section in the README about that https://github.com/contentful/contentful.js/pull/244
@bellizio the contentful js SDK is cross-platform and when we distribute it we include browser and node version, sometimes build tools picks the wrong distribution it is hard to keep up with all of them. I don’t think that will be the problem with just contentful.js but I am sure some other libraries might have this issue with the new angular. the
pathsproperty is telling angular to pick the right distribution. Consider that as a workaround for now until I have more time to dive deeper into angular build system and hopefully fix that.Best, Khaled
Thanks a lot, I will try to debug the issue
Hey @bellizio, Haven’t tried the SDK with angular 6 but I will give it try next week and let you know.
Best, Khaled