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

getNodeVersion doesn't work properly in angular when using algolia instant search #82

Closed
jbaranski opened this issue Jul 12, 2019 · 4 comments · Fixed by #88
Closed
Labels

Comments

@jbaranski
Copy link

jbaranski commented Jul 12, 2019

contentful-sdk-core/lib/utils.js

export function getNodeVersion () {
  return process.versions.node ? `v${process.versions.node}` : process.version
}

https://community.algolia.com/angular-instantsearch/getting-started.html (notice the workaround)

process.env.DEBUG exist, so process object exists but process.versions is not present. Your code throws an error when creating a client in angular in this scenario.

"TypeError: Cannot read property 'node' of undefined
    at getNodeVersion (<my local app>.js:2468:27)
    at createHttpClient (<my local app>js:2061:110)
    at createClient (<my local app>js:2596:90)
    at new ContentfulService (<my local app>js:4256:89)
    at http://localhost:4200/vendor.js:59235:15
    at _callFactory (http://localhost:4200/vendor.js:84310:20)
    at _createProviderInstance (http://localhost:4200/vendor.js:84253:26)
    at resolveNgModuleDep (http://localhost:4200/vendor.js:84212:17)
    at NgModuleRef_.get (http://localhost:4200/vendor.js:85305:16)
    at resolveNgModuleDep (http://localhost:4200/vendor.js:84217:29)"
@jbaranski jbaranski changed the title getNodeVersion doesn't work properly getNodeVersion doesn't work properly in angular Jul 12, 2019
@jbaranski jbaranski changed the title getNodeVersion doesn't work properly in angular getNodeVersion doesn't work properly in angular when using algolia instant search Jul 12, 2019
@jbaranski
Copy link
Author

If you want to use algolia instant search and contentful in the same app on angular, you can add this to the existing algolia workaround:

(window as any).process = {
    env: { DEBUG: undefined },
    browser: 'dummy'
};

@foxted
Copy link

foxted commented Sep 15, 2019

Another related issue: using contentful-js in a NativeScript application. When manually settings process.version, the SDK works perfectly.

Maybe we can put an extra check to ensure process.version exists or return null if not?

@phoebeschmidt
Copy link
Contributor

@jbaranski Thanks for opening this issue. We've had some trouble, especially with angular, since our SDKs are meant to be used in both the backend and the browser (see #58 for example). Since you have provided a workaround and our tooling maintenance is reduced at the moment, we won't be able to provide a better fix now.

I did make a PR to address @foxted's suggestion above. I'll close this issue when that PR gets merged.

@ghost
Copy link

ghost commented Apr 3, 2020

🎉 This issue has been resolved in version 6.4.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ghost ghost added the released label Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants