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

Problem starting a graphql server app implemented via nestjs #33

Closed
prabak opened this issue Jun 18, 2018 · 5 comments
Closed

Problem starting a graphql server app implemented via nestjs #33

prabak opened this issue Jun 18, 2018 · 5 comments

Comments

@prabak
Copy link

prabak commented Jun 18, 2018

Hi,

I followed the instruction to create a nestjs app successfully. I am now trying to add graphql to the server using the instructions provided here https://docs.nestjs.com/graphql/quick-start. After installing the requrired packages via yarn and adding the GraphQLModule with empty schema, i run yarn start and I get the following error:

yarn run v1.7.0
$ ts-node -r tsconfig-paths/register src/main.ts
Error: Cannot find module 'C:\Users\prabakar\Documents\web-server\src/graphql'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._resolveFilename (C:\Users\prabakar\Documents\web-server\node_modules\tsconfig-paths\lib\register.js:29:44)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\prabakar\Documents\web-server\node_modules\apollo-server-core\src\runQuery.ts:1:1)
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)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I am on windows 10, here is the content of package.json dependencies.

"dependencies": {
"@nestjs/common": "^5.0.0",
"@nestjs/core": "^5.0.0",
"@nestjs/graphql": "^3.0.0",
"@nestjs/microservices": "^5.0.0",
"@nestjs/testing": "^5.0.0",
"@nestjs/typeorm": "^5.0.0",
"@nestjs/websockets": "^5.0.0",
"@types/graphql": "^0.13.1",
"apollo-server-express": "^1.3.6",
"graphql": "^0.13.2",
"graphql-tools": "^3.0.2",
"mysql": "^2.15.0",
"reflect-metadata": "^0.1.12",
"rxjs": "^6.0.0",
"typeorm": "^0.2.7",
"typescript": "^2.8.0"
},

any ideas what is going on?

@prabak
Copy link
Author

prabak commented Jun 19, 2018

One thing I forgot to mention above is that, I started the project with the starter project found @ https://github.com/nestjs/typescript-starter.

FIX

Okay, if anyone else is having the same issue, it is do with the configuration of the tsconfig.json file. I had to change the baseUrl from "baseUrl": "./src" to "baseUrl": "./". It was searching for the graphql module in the /src directory

@4F2E4A2E
Copy link

@sgomanf
Copy link

sgomanf commented Jul 8, 2018

Same issue, after upgrading packages with "yarn upgrade" and run "yarn start" i get the following error:

$ yarn start
yarn run v1.7.0
$ ts-node -r tsconfig-paths/register src/main.ts
Error: Cannot find module 'apollo-server-core'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._resolveFilename (D:\Dev\TS\libs\nestjs-typeorm-boilerplate\node_modules\tsconfig-paths\lib\register.js:32:40)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (D:\Dev\TS\libs\nestjs-typeorm-boilerplate\node_modules\apollo-server-express\src\expressApollo.ts:3:1)
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)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

running "yarn start:prod" i get the following error:

$ yarn start:prod
yarn run v1.7.0
$ rimraf dist && tsc
node_modules/@types/graphql/validation/index.d.ts:93:8 - error TS2307: Cannot find module './rules/UniqueArgumentNames'.

93 } from './rules/UniqueArgumentNames';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@cschroeter
Copy link

cschroeter commented Aug 17, 2018

The problem is how people deal with dependencies.
If you specify your versions like ^1.2.0 you get any version which might be compatible with the version 1.20. I highly recommend throw out all those ^ carets and pin down the version numbers. Remove your yarn.lockand also your node_module folder and try it again. Happy hacking.

@lock
Copy link

lock bot commented Apr 25, 2020

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.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants