w3tecch / express-typescript-boilerplate

A delightful way to building a RESTful API with NodeJs & TypeScript by @w3tecch
MIT License
3.29k stars 904 forks source link

Error after execute "npm run setup" #54

Closed sinner closed 6 years ago

sinner commented 6 years ago

I'm obtaining an error after executing the "npm run setup" command:

root@api-express:/usr/src/app# npm run setup

express-typescript-boilerplate@3.0.0-rc.1 presetup /usr/src/app yarn install

yarn install v1.3.2
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
Done in 0.94s.

express-typescript-boilerplate@3.0.0-rc.1 setup /usr/src/app npm start setup.db express-typescript-boilerplate@3.0.0-rc.1 start /usr/src/app nps "setup.db" nps is executing setup.db : nps db.migrate && nps db.seed nps is executing db.migrate : nps banner.migrate && nps config && ts-node -F ./node_modules/typeorm/cli.js migrations:run nps is executing banner.migrate : ts-node -F ./commands/banner.ts migrate /bin/sh: 1: ts-node: not found The script called "banner.migrate" which runs "ts-node -F ./commands/banner.ts migrate" failed with exit code 127 https://github.com/kentcdodds/nps/blob/v5.7.1/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code The script called "db.migrate" which runs "nps banner.migrate && nps config && ts-node -F ./node_modules/typeorm/cli.js migrations:run" failed with exit code 127 https://github.com/kentcdodds/nps/blob/v5.7.1/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code The script called "setup.db" which runs "nps db.migrate && nps db.seed" failed with exit code 127 https://github.com/kentcdodds/nps/blob/v5.7.1/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code npm ERR! file sh npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR! express-typescript-boilerplate@3.0.0-rc.1 start: nps "setup.db" npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the express-typescript-boilerplate@3.0.0-rc.1 start 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!     /root/.npm/_logs/2018-01-22T06_26_48_050Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! express-typescript-boilerplate@3.0.0-rc.1 setup: `npm start setup.db`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the express-typescript-boilerplate@3.0.0-rc.1 setup 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!     /root/.npm/_logs/2018-01-22T06_26_48_069Z-debug.log

Even, I had to install nps and typeorm globally, before this error. Any glue?

My .env file is this:

` #

APPLICATION

# APP_NAME="coin-sparta-api" APP_ROUTE="http://localhost:3000" APP_ROUTE_PREFIX="/api" APP_BANNER=false

#

LOGGING

# LOG_LEVEL="warning" LOG_JSON=false LOG_OUTPUT="dev"

#

AUTHORIZATION

# AUTH_ROUTE="http://localhost:3333/tokeninfo"

#

DATABASE

# DB_TYPE="mongodb" DB_HOST=mongodb DB_PORT=27017 DB_DATABASE="coinsparta" DB_LOGGING=false

#

GraphQL

# GRAPHQL_ENABLED=true GRAPHQL_ROUTE="/graphql"

#

Swagger

# SWAGGER_ENABLED=true SWAGGER_ROUTE="/swagger" SWAGGER_FILE="api/swagger.json" SWAGGER_USERNAME="admin" SWAGGER_PASSWORD="1234"

#

Status Monitor

# MONITOR_ENABLED=true MONITOR_ROUTE="/monitor" MONITOR_USERNAME="admin" MONITOR_PASSWORD="1234" `

dweber019 commented 6 years ago

Hi @sinner

The issue is that ts-node is missing.

Please do the following first:

Please also provide your operating system and version you used.

sinner commented 6 years ago

Hi @dweber019! Thank you again for your response:

After solving that you have said, I have another error (Error: Cannot find module '/usr/src/app/migrate'), here the detail of the error:

` $npm run setup

express-typescript-boilerplate@3.0.0-rc.1 presetup /usr/src/app yarn install

yarn install v1.3.2 [1/5] Validating package.json... [2/5] Resolving packages... success Already up-to-date. Done in 0.99s.

express-typescript-boilerplate@3.0.0-rc.1 setup /usr/src/app npm start setup.db

express-typescript-boilerplate@3.0.0-rc.1 start /usr/src/app nps "setup.db"

nps is executing setup.db : nps db.migrate && nps db.seed nps is executing db.migrate : nps banner.migrate && nps config && ts-node -F ./node_modules/typeorm/cli.js migrations:run nps is executing banner.migrate : ts-node -F ./commands/banner.ts migrate Error: Cannot find module '/usr/src/app/migrate' at Function.Module._resolveFilename (module.js:538:15) at Function.Module._load (module.js:468:25) at Function.Module.runMain (module.js:684:10) at Object. (/usr/local/lib/node_modules/ts-node/src/_bin.ts:177:12) at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3) at Function.Module.runMain (module.js:684:10) The script called "banner.migrate" which runs "ts-node -F ./commands/banner.ts migrate" failed with exit code 1 https://github.com/kentcdodds/nps/blob/v5.7.1/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code The script called "db.migrate" which runs "nps banner.migrate && nps config && ts-node -F ./node_modules/typeorm/cli.js migrations:run" failed with exit code 1 https://github.com/kentcdodds/nps/blob/v5.7.1/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code The script called "setup.db" which runs "nps db.migrate && nps db.seed" failed with exit code 1 https://github.com/kentcdodds/nps/blob/v5.7.1/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! express-typescript-boilerplate@3.0.0-rc.1 start: nps "setup.db" npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the express-typescript-boilerplate@3.0.0-rc.1 start 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! /root/.npm/_logs/2018-01-23T05_57_03_814Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! express-typescript-boilerplate@3.0.0-rc.1 setup: npm start setup.db npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the express-typescript-boilerplate@3.0.0-rc.1 setup 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! /root/.npm/_logs/2018-01-23T05_57_03_837Z-debug.log `

Moreover, my node version is 8.9.4 and my operating system is Mac OS High Sierra, but I'm using your docker-compose configuration.

sinner commented 6 years ago

This project doesn't work