Hi,
My new project is to learn how to use Node.js.
It’s a whole new world for me and I think it will help me connect my Doc to APIs that Coda Pack will never ever support, my country’s mail service API for instance that uses SOAP API.
The thing is I’m stuck in the beginning.
I followed the instructions in https://www.npmjs.com/package/coda-js
I got to install it using the command: npm install --save coda-js then I created a test file below using as instructed in the page using Atom. I also added my token.
import { Coda } from ‘coda-js’;
const coda = new Coda(’*********--’); // insert your token
// trick for using async in a script
(async () => {
const whoAmI = await coda.whoAmI();
console.log(whoAmI);
})().catch((error) => console.log(error));
When I run “node mycode.js” I receive the error message below.
C:\Users\breno\teste>node teste5
(node:15152) Warning: To load an ES module, set “type”: “module” in the package.json or use the .mjs extension.
C:\Users\breno\teste\teste5.js:2
import Coda from ‘coda-js’;
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
I even tried to install globally -g, but I still I got the same message.