Node.js Backend

Gravatar

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.

Gravatar

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.

Gravatar

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", // ... }

Solved
Gravatar

In a Node.js backend application, there is typically no predefined category specifically dedicated to Node.js. Node.js is a JavaScript runtime that allows you to build server-side applications, so it falls under the "Backend Development" or "Server-Side Development" category.

When categorizing or tagging your project or question, you can use terms such as:

  1. Backend Development Drift Boss
  2. Server-Side Development
  3. Node.js Development
  4. JavaScript Development (if your question or project involves JavaScript in general)
  5. Web Development (if your Node.js backend is part of a web application)

These categories help provide context and clarity when discussing or seeking assistance with Node.js backend development.

User profile image

There are no words to express how much I appreciate this post.I'm blown away by this post; whoever wrote it must be an exceptional human being.I appreciate you telling us about this.We appreciate your candor and openness in answering our questions. dordle game

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.