0

How can I use

process.cwd() 

within Angular2 Component with TypeScript? What do I have to import?

The following in the constructor

console.log("Where I am: ", process.cwd());

outputs the error:

ORIGINAL EXCEPTION: ReferenceError: process is not defined
ORIGINAL STACKTRACE:
ReferenceError: process is not defined

As I could use process.cwd() and __dirname natively in my JavaScript files, I am wondering, why it does not work instantly?

What do I have to import? Is it my addiction to nodeJS? Or my wrong assumptions: what in node works must work everywhere?

1 Answers1

0

Try this:

declare var process: any;

Place it before @Component; It won't give you full intellisense but it satisfies the compiler.

hholtij
  • 2,906
  • 6
  • 27
  • 42