feathers-plus / cli

FeathersJS CLI supporting both REST and GraphQL architectural concepts and their query languages.
https://generator.feathers-plus.com/
Other
43 stars 7 forks source link

Generated TypeScript with custom sources folder fails to "npm start" #12

Closed iva2k closed 6 years ago

iva2k commented 6 years ago

Steps to reproduce

npm install -g @feathers-plus/cli
mkdir feathers-app
cd feathers-app
feathers-plus generate options
# choose all defaults, except "Generate TypeScript code?" Yes

feathers-plus generate app
# choose all defaults, except enter different folder for source files, e.g. 'server'

Then run

npm start

Expected behavior

Server should compile and run.

Actual behavior

Server fails to start:

C:\dev\ionic3-feathersplus-try2\api>npm start

> api@0.0.0 start C:\dev\ionic3-feathersplus-try2\api
> ts-node --files src/

Error: Cannot find module 'C:\dev\ionic3-feathersplus-try2\api\src'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at Object.<anonymous> (C:\dev\ionic3-feathersplus-try2\api\node_modules\ts-node\src\bin.ts:147:12)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! api@0.0.0 start: `ts-node --files src/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the api@0.0.0 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!     C:\Users\~~~\AppData\Roaming\npm-cache\_logs\2018-07-18T16_39_21_711Z-debug.log
iva2k commented 6 years ago

Looks like package.json generator has hardcoded "src/" for this line in "scripts":

    "start": "ts-node --files src/",

However, with changing it to:

    "start": "ts-node --files server/",

it gets a little further, but then there's another error:

C:\dev\ionic3-feathersplus-try2\api>npm start

> api@0.0.0 start C:\dev\ionic3-feathersplus-try2\api
> ts-node --files server/

C:\dev\ionic3-feathersplus-try2\api\node_modules\ts-node\src\index.ts:261
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: Γ¿» Unable to compile TypeScript:
server/app.hooks.ts(4,30): error TS7016: Could not find a declaration file for module 'feathers-hooks-common'. 'C:/dev/ionic3-feathersplus-try2/api/node_modules/feathers-hooks-common/lib/index.js' implicitly has an
 'any' type.
  Try `npm install @types/feathers-hooks-common` if it exists or add a new declaration (.d.ts) file containing `declare module 'feathers-hooks-common';`

    at createTSError (C:\dev\ionic3-feathersplus-try2\api\node_modules\ts-node\src\index.ts:261:12)
    at getOutput (C:\dev\ionic3-feathersplus-try2\api\node_modules\ts-node\src\index.ts:367:40)
    at Object.compile (C:\dev\ionic3-feathersplus-try2\api\node_modules\ts-node\src\index.ts:557:11)
    at Module.m._compile (C:\dev\ionic3-feathersplus-try2\api\node_modules\ts-node\src\index.ts:439:43)
    at Module._extensions..js (module.js:663:10)
    at Object.require.extensions.(anonymous function) [as .ts] (C:\dev\ionic3-feathersplus-try2\api\node_modules\ts-node\src\index.ts:442:12)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! api@0.0.0 start: `ts-node --files server/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the api@0.0.0 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!     C:\Users\~~~\AppData\Roaming\npm-cache\_logs\2018-07-18T16_45_04_576Z-debug.log
iva2k commented 6 years ago

Found hardcoded "src" in tsconfig.json:

  "include": [
    "src/index.ts",
    "src/typings.d.ts"
  ],

Changed to:

  "include": [
    "server/index.ts",
    "server/typings.d.ts"
  ],

after that npm start works ok, server runs.

eddyystop commented 6 years ago

Fixes published as f+/cli v0.4.15

Thanks for all the stuff you are finding.

iva2k commented 6 years ago

@eddyystop Welcome! Thanks for fixing them right away!

iva2k commented 5 years ago

The issue came back.

npm install -g @feathers-plus/cli
mkdir feathers-app
cd feathers-app
feathers-plus generate options
# choose all defaults, except "Generate TypeScript code?" Yes

feathers-plus generate app
# choose all defaults, except enter different folder for source files, e.g. 'server'

Now grepping for 'src':

package.json:

    "start:seed": "cross-env NODE_ENV= ts-node --files src/ --seed",

tsconfig.json:

    "rootDir": "./src",                    /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
iva2k commented 5 years ago

No way for me to reopen this, filed new issue:

38