You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get an error running the tests...
SyntaxError: Cannot use import statement outside a module
Steps to reproduce:
clone the repository
cd into the project directory and run npm i
run npm run test
I also get an error trying to do the following in Node, which I believe is possibly related...
Using Node 18 LTS create a simple project and
run "npm i comet-js-sdk"
create a file with the "js" extension
import the library like this... import comet from "comet-js-sdk"; or import { CometServer } from "comet-js-sdk";
run the file with node
The error is
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/path/to/my-project/node_modules/comet-js-sdk/dist/mjs/lib/output' imported from /path/to/my-project/node_modules/comet-js-sdk/dist/mjs/index.js
The text was updated successfully, but these errors were encountered:
Thanks for raising this issue - both problems are caused by running in script mode instead of module mode.
I can confirm the issue with the Jest tests. To run the tests in module mode, try this (for Node 16 or 18):
NODE_OPTIONS=--experimental-vm-modules npm run test
For your test app, you can either
(A) get node.js into Module mode by renaming your .js file to .mjs and running with the --experimental-vm-modules argument; or
(B) embrace the classic script mode, and load the SDK with require instead of import, using the provided CommonJS instructions: const { CometServer } = require('comet-js-sdk')
Hope this helps - please let us know if you manage to resolve the issue,
I get an error running the tests...
SyntaxError: Cannot use import statement outside a module
Steps to reproduce:
npm i
npm run test
I also get an error trying to do the following in Node, which I believe is possibly related...
import comet from "comet-js-sdk";
orimport { CometServer } from "comet-js-sdk";
The error is
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/path/to/my-project/node_modules/comet-js-sdk/dist/mjs/lib/output' imported from /path/to/my-project/node_modules/comet-js-sdk/dist/mjs/index.js
The text was updated successfully, but these errors were encountered: