Error: App fails, after npm install

/home/sibabalwe/Desktop/mflix/src/index.js:1

(function (exports, require, module, __filename, __dirname) { import app from “./server”;
^^^^^^

SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at loader (/home/sibabalwe/Desktop/mflix/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/sibabalwe/Desktop/mflix/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)

I ran : npm start, and i got this error

Hi @sibabalwe-qamata,

  • Has npm start worked for you before or is this the first time you are running it?
  • Is your node version 10.x? to test please run node -v
  • did you run npm install before starting the app?

@yulia_genkina I downloaded the app files, and ran npm install followed by npm start… changed the node version to 10.x. after that i tried npm start

Regardless of doing all that, the app still fails to run

Hi @sibabalwe-qamata,

It could be that some of that packages didn’t install correctly during npm install

Did you modify any of the files except for the .ini file before running the npm install?

additionally, you can try npm audit fix before trying npm install again

please paste the error message in here if it changes from what you were getting in the original post.

I have node v10.10
I ran:
npm install
npm start
And then got the error:
MongoParseError: URI malformed, cannot be parsed
I then ran
npm audit fix
npm start again
and got the same error.

…continuing from last post…

Looking through the code it seems like /src/index.js is trying to read a non-existent dot env file and the path for connecting to my database is not there.

Following the comments in the dotenv_unix file plus creating a mongodb user and connection string through Atlas gave me the missing parts.

npm start
works now.

1 Like