FrontendMasters / intro-to-graphql

[Course] Introduction to GraphQL
192 stars 289 forks source link

lesson 1: Error: Cannot find module '.../dist/index.js' #5

Open Vince2301 opened 5 years ago

Vince2301 commented 5 years ago

In lesson 1, I get this error

yarn start
yarn run v1.16.0
$ node dist/index.js
internal/modules/cjs/loader.js:626
    throw err;
    ^

Error: Cannot find module '/Users/vincentleleux/introg/dist/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 Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
error Command failed with exit code 1.

There is indeed no dist folder and the package.json got this line : "start": "node dist/index.js"

so why is it not throwing an error for you ?

rozenteno commented 5 years ago

Hello! What I did was:

To connect to db, make sure you follow these instructions: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/#install-mongodb-community-edition-on-macos if you're on Mac.

I don't know if is the correct way of doing it but it worked for me. Regards!

JhoanLT commented 4 years ago

The dist folder is generated by running the yarn build command.

Newville23 commented 3 years ago

Hey @Vince2301 , You just need to run yarn build and then yarn start :)

erinoggz commented 3 years ago

Edit nest-cli.json

{
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "entryFile": "your/main/js/path"
}