pawelgalazka/tasksfile

Typescript support out of the box?

Closed this issue · 1 comments

Is there any way to support typescript without a package.json?
Let's suppose I would like to have a tasksfile.ts without a package.json.
For this I tried to:
I installed ts-node, typescript and tasksfile globally (-g) and imported as file below.

import { cli } from 'tasksfile'
function hello(options, name = 'Mysterious') {
  console.log(`Hello ${name}!`)
}
cli({
  hello
})

And I executed: ts-node tasksfile.ts.
But getting...

TSError: ⨯ Unable to compile TypeScript:
tasksfile.ts:1:21 - error TS2307: Cannot find module 'tasksfile'.

1 import { cli } from 'tasksfile'
                      ~~~~~~~~~~~

Am I doing something wrong? Thanks in advance! 🙃

In Node.js, require/import doesn't look in the folder where global modules are installed. You need to install tasksfile within the project directory to be able to import it.