chaijs / chai-http

HTTP Response assertions for the Chai Assertion Library.
http://chaijs.com/plugins/chai-http
634 stars 113 forks source link

Not able to require the chai-http as commonjs() in latest version #335

Closed Nanagoud007 closed 3 months ago

Nanagoud007 commented 3 months ago

when i require module like this const chai = require('chai'); const expect = chai.expect; chai.use(require('chai-http'));

when i run the test case i am getting this error my project is all depending on require so i can't go to import Error [ERR_REQUIRE_ESM]: require() of ES Module /home/nanagoudt/numo_backend_repos/multitenant-cpuptime-service/node_modules/chai-http/index.js from /home/nanagoudt/numo_backend_repos/multitenant-cpuptime-service/test/write-status-logs.test.js not supported. Instead change the require of index.js in /home/nanagoudt/numo_backend_repos/multitenant-cpuptime-service/test/write-status-logs.test.js to a dynamic import() which is available in all CommonJS modules.

43081j commented 3 months ago

The latest version is esm only. You will need to use a dynamic import or the older version until you migrate your own code to esm