Npm start doesn't work

I exactly followed the readme lecture, everything went fine, but when I used the npm start command, I got the following error. Even though after hassling using google, I’m still unable to start the application:

D:\Learn\mflix-js>npm start

server@1.0.0 start D:\Learn\mflix-js
nodemon -L ./index.js

[nodemon] 1.19.1
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node ./index.js
internal/modules/cjs/loader.js:626
throw err;
^

Error: Cannot find module ‘babel-core/register’
Require stack:
D:\Learn\mflix-js\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)
at Function.Module._load (internal/modules/cjs/loader.js:527:27)
at Module.require (internal/modules/cjs/loader.js:681:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object. (D:\Learn\mflix-js\index.js:1:1)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:837:10) {
code: ‘MODULE_NOT_FOUND’,
requireStack: [ ‘D:\Learn\mflix-js\index.js’ ]
}
[nodemon] app crashed - waiting for file changes before starting…

Even I tried installing bable using

npm install @babel/core --save

and it didn’t worked and said

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ahsan Ali\AppData\Roaming\npm-cache_logs\2019-08-21T06_16_34_572Z-debug.log

I’m in the same situation

Please take a look at the following post:

Let me know if you are still facing issue.

Kanika

2 Likes

have you got any solution yet ?

Ahsan_72923:
Check this thread here, if you are still encountering this problem :

npm-install-error-and-npm-start-cannot-find-module

Yes, I resolved as per the suggestion “… To resolve this I deleted the package-lock.json file, ran npm audit fix and npm install …”

1 Like

after trying your commands, I’m getting Cannot read property 'split' of null error :cold_sweat:

Read the topic of this link until the end have another suggestion if you are using windows:

I don’t know how it started, but eventually after rolling through different threads above, it somehow got to start.
Now, although it’s working fine, but I’m still getting a warning
(node:7852) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to MongoClient.connect. listening on port 5000
Is it safe to ignore the above warning ? or I need to do something to remove this.
And thanks for helping me out all the guys out there.

If it works, then don’t worry about it :slight_smile:

Just do your tickets and cross your fingers :blush:

I am at 3rd chapter and I just did that yarn thing … I have a github warning about some mem leak component, not so worried, this is a learning environment, it is never going to be a life app.

happy coding … but on the side note, it can be a good practice for future projects to update package file and make it your goal to get error free program start, but maybe after this course is over.

regards,

1 Like

Alright, thanks for your response.
I’m at the last step of README tutorial, my application is running fine and I check it through browser too.
Now then I run the npm test -t connection-pooling.test.js command, I get the following error

server@1.0.0 test D:\Learn\mflix-js
jest --passWithNoTests “connection-pooling.test.js”

Determining test suites to run…Setup Mongo Connection
(node:17756) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to MongoClient.connect.
FAIL test/connection-pooling.test.js
Connection Pooling
× Connection pool size is 50 (317ms)

● Connection Pooling › Connection pool size is 50

expect(received).toBe(expected) // Object.is equality

Expected: 50
Received: undefined

Difference:

  Comparing two different types of values. Expected number but received undefined.

   8 |   test("Connection pool size is 50", async () => {
   9 |     const response = await MoviesDAO.getConfiguration()
> 10 |     expect(response.poolSize).toBe(50)
     |                               ^
  11 |   })
  12 | })
  13 |

  at toBe (test/connection-pooling.test.js:10:31)
  at tryCatch (node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:62:40)
  at Generator.invoke [as _invoke] (node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:296:22)
  at Generator.prototype.<computed> [as next] (node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:114:21)
  at step (node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
  at node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 5.739s, estimated 6s
Ran all test suites matching /connection-pooling.test.js/i.
Teardown Mongo Connection

What to do now ?

You don’t need to run this test yet! This was just for explaining on how to run the unit tests.

Kanika

1 Like

I am still getting the crash report whenever i tried npm start[quote=“Ahsan_72923, post:1, topic:32394, full:true”]
I exactly followed the readme lecture, everything went fine, but when I used the npm start command, I got the following error. Even though after hassling using google, I’m still unable to start the application:

D:\Learn\mflix-js>npm start

server@1.0.0 start D:\Learn\mflix-js
nodemon -L ./index.js

[nodemon] 1.19.1
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node ./index.js
internal/modules/cjs/loader.js:626
throw err;
^

Error: Cannot find module ‘babel-core/register’
Require stack:
D:\Learn\mflix-js\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)
at Function.Module._load (internal/modules/cjs/loader.js:527:27)
at Module.require (internal/modules/cjs/loader.js:681:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object. (D:\Learn\mflix-js\index.js:1:1)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:837:10) {
code: ‘MODULE_NOT_FOUND’,
requireStack: [ ‘D:\Learn\mflix-js\index.js’ ]
}
[nodemon] app crashed - waiting for file changes before starting…

So the M220 JavaScript project uses Babel v6.x atm and therefore I do not think installing anything with @babel will work since they use that nomenclature for v7+.

    "babel-core": "^6.26.3",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-1": "^6.24.1",
    "babel-register": "^6.26.0",
    "babel-runtime": "^6.26.0",

I have gone ahead an downloaded the handout zip file. Unpacked it, ran npm i then npm audit fix, change the name of the correct environment file and set the URI to my cluster. And had no problems with npm start

Perhaps it maybe a good idea to completely remove the folder you created for the course and start again. With

  1. Create folder called M220, cd into it
  2. Download zip file into that folder
  3. Unpack
  4. run npm install
  5. run npm audit fix
  6. set up .env file
  7. try npm start again.

If there are still issues let me know

2 Likes

I don’t think, it will work, because I already have tried all of the above steps.

Well perhaps you should try the steps, making sure to completely delete the entire folder and start again. I have done it 3 times with success each time just to make sure I am not leading you astray. :slight_smile: And if not I apologize.

And lastly you can try to go into the index.js file at the top level and change the following command.

# from
require("babel-core/register")
# to 
require('babel-register')

As per https://babeljs.io/docs/en/6.26.3/babel-register

I do hope we can get this working for you :exclamation:

1 Like

@natac13 thanks you, I just got it to work

1 Like

Can I ask what did the trick for any future student with same issue?

again getting same error

MongoParseError: URI malformed, cannot be parsed
at parseConnectionString (C:\mfix\node_modules\mongodb\lib\core\uri_parser.js:502:21)
at connect (C:\mfix\node_modules\mongodb\lib\operations\connect.js:266:3)
at ConnectOperation.execute (C:\mfix\node_modules\mongodb\lib\operations\connect.js:191:5)
at C:\mfix\node_modules\mongodb\lib\operations\execute_operation.js:109:26
at new Promise ()
at executeOperation (C:\mfix\node_modules\mongodb\lib\operations\execute_operation.js:102:10)
at MongoClient.connect (C:\mfix\node_modules\mongodb\lib\mongo_client.js:216:10)
at Function.MongoClient.connect (C:\mfix\node_modules\mongodb\lib\mongo_client.js:379:22)
at Object. (C:/mfix/src/index.js:23:13)
at Module._compile (internal/modules/cjs/loader.js:868:30)
[nodemon] app crashed - waiting for file changes before starting…

Try the steps that @natac13 told, that worked fine for me.