Node.js Backend


Can´t find the category for the node.js backend.

I set up the backend as described in the readme. With a little bit trouble with the postgres part everything should be fine now, but i am receiving the follow error after starting the backend with "yarn start:dev":

SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:355:18) at wrapSafe (node:internal/modules/cjs/loader:1022:15) at Module.compile (node:internal/modules/cjs/loader:1056:27) at Module.compile (/Users//workspace/salesbackend/nodemodules/pirates/lib/index.js:99:24) at Module.extensions..js (node:internal/modules/cjs/loader:1121:10) at Object.newLoader as .js at Module.load (node:internal/modules/cjs/loader:972:32) at Function.Module._load (node:internal/modules/cjs/loader:813:14) at Function.executeUserEntryPoint as runMain at Object. (/Users//workspace/salesbackend/nodemodules/@babel/node/lib/babel-node.js:173:12)

[nodemon] app crashed - waiting for file changes before starting...

What am i doing wrong?

Thank you in advance for your help.


Hi, could you please clarify which product you bought? And could you please tell did you run yarn reset? Also please mention version of your NodeJS.


This error can happen in different cases depending on whether you're working with JavaScript on the server-side with Node.js , or client-side in the browser. There are several reasons behind "Cannot use import statement outside a module" error, and the solution depends on how you call the module or script tag.

Add type="module" inside the script tag

When working with ECMAScript modules and JavaScript module import statements in the browser, you'll need to explicitly tell the browser that a script is module. To do this, you have to add type="module" onto any ‹script› tags that point to a JavaScript module. Once you do this you can import that module without issues.

If you are working on Node.js or react applications and using import statements instead of require to load the modules, then ensure your package.json has a property "type": "module" as shown below.

{ // ... "type": "module", // ... }

Cookie Consent

By continuing to browse or by clicking 'OK', you agree to the storing of cookies on your device to enhance your site experience and for analytical purposes. To learn more about how we use cookies, please see our cookies policy.