Nest-cli: Cannot find module 'typescript'

Created on 19 Dec 2018  路  6Comments  路  Source: nestjs/nest-cli

I'm submitting a...


[ ] 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.

Current behavior

nest new xxxx
cd xxxx/
nest g module user

Error

Error: Cannot find module 'typescript'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:659:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/@nestjs/cli/node_modules/@nestjs/schematics/utils/metadata.manager.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:723:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
Failed to execute command: "/usr/local/lib/node_modules/@nestjs/cli/node_modules/.bin/schematics" @nestjs/schematics:module --name=game --no-dry-run --spec --language="ts" --sourceRoot="src"

Expected behavior

Should generate module

Minimal reproduction of the problem with instructions

nest new xxxx
cd xxxx/
nest g module user

What is the motivation / use case for changing the behavior?

Environment

[System Information]
OS Version     : macOS High Sierra
NodeJS Version : v11.4.0
NPM Version    : 6.4.1
[Nest Information]
common version : 5.4.0
core version   : 5.4.0

Most helpful comment

You probably don't have typescript globally
just type npm install -g typescript in your terminal

All 6 comments

I'm having the same issue. I am unable to generate anything.

[System Information]
OS Version     : macOS
NodeJS Version : v10.14.2
NPM Version    : 6.4.1
[Nest Information]
common version : 5.4.0
core version   : 5.4.0

I just downgraded my @nestjs/cli to 5.6.3, and I'm still experiencing the issue.

It must be something to do with my machine, but I've added typescript manually to my project and also to my machine globally.

Does the CLI have extra pre-conditions that I'm missing?

You probably don't have typescript globally
just type npm install -g typescript in your terminal

typescript installed globally should solve this issue. Also, I have just pushed a small fix that should make the installation of typescript optional

installing typescript globally solved the issue for me too 馃憤

typescript installed globally should solve this issue. Also, I have just pushed a small fix that should make the installation of typescript optional

Thank you, but I was having the same issue setting up Nest today so I think the small fix didn't work.

Was this page helpful?
0 / 5 - 0 ratings