Npm start error

having issues starting the server locally, got this error

/home/innextinit/Downloads/mflix-js/src/index.js:1
import app from “./server”;
^^^^^^
SyntaxError: Cannot use import statement outside a module

when i go into the package.json to include the “type”: “module” i get this error

file:///home/innextinit/Downloads/mflix-js/index.js:1
require("@babel/register")
^
ReferenceError: require is not defined
at file:///home/innextinit/Downloads/mflix-js/index.js:1:1

Make sure you are running from mflix-js folder. If yes, then please check which version you are using for NodeJS or npm?

Kanika

I have the same problem. It’s sad that this project don’t run out of the box. I work with node daily, so my setup is not the problem. Running from the directory the package.json is, with node 10.23.1 (tried node 14 too).

Using the code from the GitHub repo worked (GitHub - mongodb-university/mflix-js). But you have to delete package-lock.json before running npm install.

This could happen when a few of the hidden files are left out. After you download the mflix-js.zip file, copy and paste this command:

unzip mflix-js -d mflix-js && 
cd mflix-js && 
npm install && 
npm start

It should start the application on port 5000.

If anything fails it can be run one by one.

1 Like