cannot use import statement outside a module node

What am i doing wrong please? The support for node is currently in experimental stage. Without this, if we start using something from @zulip/shared and then try to run Jest, it fails with a SyntaxError. To create a server I am going to use Express. In my setup, I was importing a module called, AbModule (AbModule has class AbClassName) from my script testab.ts. Cannot use import statement outside a module Unexpected token ‘export’ Based on your screenshot ... you are using Java code in a JavaScript file.... Those are 2 different languages. You can name this script anything you like. You can check out the package.json file after initializing your project as an npm project. This done by babel-watch that also takes care of re-starting Nodejs web server. You can also visit http://localhost3000/ in a browser window to verify the result and see if the server is working or not. ... Nodejs cannot execute import statements by default. Update 2: Since Node 12, you can use either the .mjs extension or set "type": "module" in Further, the server has to work with the client in a way that the client can consume the API easily. Concerning the drawbacks, not being able to use React components may not be a problem, at least for simple documentation. John: But I don’t have a package.json… Lea: Run npm init, it will generate it for you! It is an Uncaught syntax error. You can fix the issue by building the script file and importing them. To continue to read this article, please make sure you have following installed on your local machine: I call it a mock because I am going to start from scratch to build this setup. I want consistency when working on full-stack applications for my day job. How to use ESLint in Node.js Applications? Open in app. Dismiss Join GitHub today.