Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Vince2301 opened this issue Jun 20, 2019 · 4 comments
Open

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

Vince2301 opened this issue Jun 20, 2019 · 4 comments

Comments

@Vince2301
Copy link

Vince2301 commented Jun 20, 2019

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
Copy link

Hello! What I did was:

  • Change the "start" command in package.json to -> node src/index.js run with yarn. After that, the folder dist should be created.
  • Now change the same line to node dist/index.js

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
Copy link

JhoanLT commented Apr 3, 2020

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

@Newville23
Copy link

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

@erinoggz
Copy link

erinoggz commented Aug 15, 2021

Edit nest-cli.json

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants