Cannot find module 'ts-node/register'

lenny picture lenny · Dec 1, 2016 · Viewed 44.1k times · Source

I want to use mocha to test my TypeScript/Angular2 project. I tried to use ts-node as described here:

npm install -g ts-node

but when running

mocha --require ts-node/register -t 10000 ./**/*.unit.ts

I get an error

Cannot find module 'ts-node/register'

What am I missing here?

Answer

Louie Bertoncin picture Louie Bertoncin · May 29, 2017

Since the answer that works for a lot of people appears to be hidden in the comments, I'll post it as an actual answer to the question, now that it appears the question has been reopened.

I had this problem as well. Not sure why this Q has been closed. but installing ts-node locally fixes this. npm install ts-node --save-dev

Thanks @Anita, as this was the answer that worked for me too.