I am trying to get my first TypeScript and DefinitelyTyped Node.js application up and running, and running into some errors.
I am getting the error "TS2304: Cannot find name 'require' " when I attempt to transpile a simple TypeScript Node.js page. I have read through several other occurrences of this error on Stack Overflow, and I do not think I have similar issues. I am running at the shell prompt the command:
tsc movie.server.model.ts.
The contents of this file are:
'use strict';
/// <reference path="typings/tsd.d.ts" />
/* movie.server.model.ts - definition of movie schema */
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var foo = 'test';
The error is thrown on the var mongoose=require('mongoose')
line.
The contents of the typings/tsd.d.ts file are:
/// <reference path="node/node.d.ts" />
/// <reference path="requirejs/require.d.ts" />
The .d.ts file references were placed in the appropriate folders and added to typings/tsd.d.ts by the commands:
tsd install node --save
tsd install require --save
The produced .js file seems to work fine, so I could ignore the error. But I would appreciate knowing why this error occurs and what I am doing wrong.
when I attempt to transpile a simple ts node page
< how are you transpiling ... which utility – Smolderimport { mongoose } from 'mongoose'
? – Pannier