Error: Cannot find module 'ts-morph'

See original GitHub issue

Bug Report

Current behavior

I want to just run the graphql example in this repo, so I cloned this repo, and cd sample\12-graphql-schema-first, executed yarn and npx ts-node src\generate-typings.ts, then I got the following errors.

D:\code\node\nest\sample\12-graphql-schema-first>yarn
yarn install v1.22.5
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
warning @nestjs/cli > webpack > watchpack > watchpack-chokidar2 > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
warning @nestjs/cli > webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning @nestjs/cli > webpack > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
warning @nestjs/cli > webpack > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
warning jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > request > har-validator@5.1.5: this
[2/4] Fetching packages...
info fsevents@2.1.3: The platform "win32" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "win32" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "@nestjs/graphql > @nestjs/mapped-types@0.0.5" has incorrect peer dependency "class-transformer@^0.2.3".
warning "@nestjs/graphql > apollo-server-core > graphql-upload@8.1.0" has incorrect peer dependency "graphql@0.13.1 - 14".
warning "@nestjs/graphql > @apollo/gateway > apollo-graphql@0.4.5" has incorrect peer dependency "graphql@^14.2.1".
warning " > graphql-subscriptions@1.1.0" has incorrect peer dependency "graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0 || ^14.0.0".
warning " > @nestjs/schematics@7.1.1" has incorrect peer dependency "typescript@^3.4.5".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 468.32s.

D:\code\node\nest\sample\12-graphql-schema-first>npx ts-node src\generate-typings.ts
(node:34944) UnhandledPromiseRejectionWarning: Error: Cannot find module 'ts-morph'
Require stack:
- D:\code\node\nest\sample\12-graphql-schema-first\node_modules\@nestjs\graphql\dist\graphql-ast.explorer.js
- D:\code\node\nest\sample\12-graphql-schema-first\node_modules\@nestjs\graphql\dist\federation\graphql-federation.module.js
- D:\code\node\nest\sample\12-graphql-schema-first\node_modules\@nestjs\graphql\dist\federation\index.js
- D:\code\node\nest\sample\12-graphql-schema-first\node_modules\@nestjs\graphql\dist\index.js
- D:\code\node\nest\sample\12-graphql-schema-first\node_modules\@nestjs\graphql\index.js
- D:\code\node\nest\sample\12-graphql-schema-first\src\generate-typings.ts
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
    at Function.Module._load (internal/modules/cjs/loader.js:923:27)
    at Module.require (internal/modules/cjs/loader.js:1140:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at D:\code\node\nest\sample\12-graphql-schema-first\node_modules\@nestjs\graphql\dist\graphql-ast.explorer.js:18:61
(Use `node --trace-warnings ...` to show where the warning was created)
(node:34944) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:34944) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

D:\code\node\nest\sample\12-graphql-schema-first>

Input Code

Not involved

Expected behavior

No errors

Possible Solution

Using npm instead of yarn.

Environment


Nest version: 7.4.4

 
For Tooling issues:
- Node version: XX  
- Platform:  

```
D:\code\node\nest\sample\12-graphql-schema-first>node -v
v14.8.0

D:\code\node\nest\sample\12-graphql-schema-first>yarn -v
1.22.5

D:\code\node\nest\sample\12-graphql-schema-first>ver

Microsoft Windows [Version 10.0.19041.450]

D:\code\node\nest\sample\12-graphql-schema-first>
```

Others:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
kamilmysliwieccommented, Nov 9, 2020

ts-morph is an optional package (for example, because it’s not needed for the code first approach). In this case, you must explicitly install it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ts-morph
TypeScript compiler wrapper for static analysis and code manipulation.. Latest version: 17.0.1, last published: a month ago.
Read more >
typescript, ts-morph module, is there access to underlying ` ...
However, I can't see a way to access the underlying ts.Node instance from a ts-morph.SourceFile instance - there are no ts-morph functions with ......
Read more >
ts-morph
ts -morph. npm version CI stable. TypeScript Compiler API wrapper. Provides an easier way to programmatically navigate and manipulate TypeScript and ...
Read more >
ts-morph
* Gets a child source file by the specified condition or undefined if not found. 227, * @param condition - Condition to check...
Read more >
ts-morph | Yarn - Package Manager
TypeScript Compiler API wrapper. Provides an easier way to programmatically navigate and manipulate TypeScript and JavaScript code. Formerly ts-simple-ast .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found