cloudinary_npm icon indicating copy to clipboard operation
cloudinary_npm copied to clipboard

Cannot import cloudinary in nodejs with "navigator undefined"

Open feiwu77777 opened this issue 4 years ago • 7 comments

Bug report for Cloudinary NPM SDK

Before proceeding, please update to latest version and test if the issue persists

Describe the bug in a sentence or two.

I can not import cloudinary in my nodeJS backend after I installed it with npm.

Below is the full log for the error.

/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:1168
var useAgent = navigator && navigator.userAgent || '';
               ^

ReferenceError: navigator is not defined
    at Module../src/namespace/cloudinary-core.js (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:1168:16)
    at __webpack_require__ (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:37:30)
    at /Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:101:18
    at /Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:104:10
    at webpackUniversalModuleDefinition (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:10:20)
    at Object.<anonymous> (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:17:3)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/feiwu/projects/inventaire/backend/node_modules/cloudinary/lib/utils/index.js:48:57)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)

Issue Type (Can be multiple)

[ x] Build - Can’t install or import the SDK [ ] Babel - Babel errors or cross browser issues [ ] Performance - Performance issues [ ] Behaviour - Functions aren’t working as expected (Such as generate URL) [ ] Documentation - Inconsistency between the docs and behaviour [ ] Incorrect Types - For typescript users who are having problems with our d.ts files [ ] Other (Specify)

Steps to reproduce

  • npm install cloudinary in terminal
  • run "const cloudinary = require('cloudinary')" in a js file

Error screenshots

Browsers (if issue relates to UI, else ignore)

[ ] Chrome [ ] Firefox [ ] Safari [ ] Other (Specify) [ ] All

Versions and Libraries (fill in the version numbers)

Cloudinary_NPM SDK version Node - 12.2.1 NPM - 8.3.0

feiwu77777 avatar Jan 02 '22 18:01 feiwu77777

same here. tried previous release with same outcome

zivlevy avatar Jan 02 '22 19:01 zivlevy

a quick fix: comment out the line at /Users/feiwu/projects/inventaire/backend/node_modules/cloudinary-core/cloudinary-core.js:1168

and ... everything works again

zivlevy avatar Jan 02 '22 20:01 zivlevy

It worked for me thank you!

feiwu77777 avatar Jan 02 '22 21:01 feiwu77777

+1, I have no wish to modify my node_modules

sinnrrr avatar Jan 02 '22 21:01 sinnrrr

Seeing this in our app as well. Assume it's related to this? https://github.com/cloudinary/cloudinary_js/pull/281

alexchao avatar Jan 03 '22 08:01 alexchao

A fix has been merged and a new version (2.12.2) was released. Please let us know if you still see any issues.

roeeba avatar Jan 03 '22 08:01 roeeba

works fine now. Thanks for you prompt response, I am impressed 👍

zivlevy avatar Jan 03 '22 15:01 zivlevy