node.js/typescript can not find local module -


when try import local file either throws error @ runtime compiling using tsc works. when make work node.js, typescript throws error @ compile time.

when do

import = require("./a"); 

node.js complains, can not find module , typescript compiles fine.

but when change to

import = require("./js/a"); 

node.js can find module typescript tells me there error.

the layout this:

js \- a.ts \- b.ts 

i compile files separately , tried searching changing root directory typescript compiler couldn't find anything.

without seeing how compiling typescript, , without seeing how attempting require() these files node, it's hard answer question.

even so, can tell both typescript , node.js expecting require() given path relative file doing require.

if have js/a.ts looked so:

import b = require("./b"); console.log(b.thing); 

and js/b.ts looked so:

var mystuff = {     thing: "i'm thing!" } export = mystuff; 

i compile both files single tsc -m commonjs ./js/a.ts

and run node with: node ./js/a.js , see output:

i'm thing! 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -