[ ] Regression
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
npm run start:prod
failed on fresh project
It should run OK.
$ npm i -g @nestjs/cli
$ nest new project-name
$ cd project-name
$ npm run start:prod
Opps! Error:
> [email protected] prestart:prod ~/project-name
> rimraf dist && tsc
> [email protected] start:prod ~/project-name
> node dist/main.js
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '~/project-name/dist/main.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:266:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start:prod: `node dist/main.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! ~/.npm/_logs/2019-01-21T02_30_39_812Z-debug.log
Nest version: 5.4.0
For Tooling issues:
- Node version: v10.9.0
- npm: 6.2.0
- Platform: Mac
Others:
You need to build it first using tsc
Tried and got same error.
The problem is:
The result after built:
โโโ src
โย ย โโโ main.js
โย ย โโโ main.js.map
โโโ test
โโโ app.e2e-spec.d.ts
โโโ app.e2e-spec.js
โโโ app.e2e-spec.js.map
While command in package.json
is "start:prod": "node dist/main.js",
Change your prestart:prod
script to the following one:
"prestart:prod": "rimraf dist && npm run build"
Same wrong
I got same issue when .ts files outside src
and test
directory.
It cames normal when I added that files to exclude
in tsconfig.build.json
.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Change your
prestart:prod
script to the following one: