0

I installed Node.js tools for Visual Studio and created a new TypeScript > Node.js > Blank Node.js console application project.

Currently I only have one file (sender.ts). Code below:

var redis = require('redis');
var client = redis.createClient(); //creates a new client

client.on('connect', function () {
    console.log('connected');
});

client.on('ready', function () { 
    client.publish('agent', 'I am sending a message.');
});

When I build the project, I get a compilation error Cannot find name 'require'. on line 1.

Can anyone help in explaining why this happens and how I can fix it?

Jacques Snyman
  • 4,115
  • 1
  • 29
  • 49

1 Answers1

0

It should be something like this:

import redis = require('redis');

or

import redis from 'redis'; 
Fayyaz Naqvi
  • 695
  • 7
  • 19