node.js - Angular2+Express+Mongoose error TS2307: Cannot find module 'mongoose' -


i'm learning angular2 start writing application angular2-express-starter, yesterday compiler can't find mongoose module.

server/shemas/product.ts(4,27): error ts2307: cannot find module 'mongoose'. 

app.ts

import * express 'express';  import { json, urlencoded } 'body-parser';  import * path 'path';  import * cors 'cors';  import * compression 'compression';  import { loginrouter } './routes/login';  import { protectedrouter } './routes/protected';  import { publicrouter } './routes/public';  import { feedrouter } './routes/feed';  import {listrouter} "./routes/list";  const app: express.application = express();  app.disable('x-powered-by');  app.use(json());  app.use(compression());  app.use(urlencoded({ extended: true }));  // allow cors local dev app.use(cors({   origin: 'http://localhost:4200' }));  // app.set('env', 'production');  //mongodb connection  var mongoose = require('mongoose'); mongoose.connect("mongodb://<my-adress>:27017");  // api routes app.use('/api/secure', protectedrouter); app.use('/api/login', loginrouter); app.use('/api/public', publicrouter); app.use('/api/feed', feedrouter); app.use('/api/list', listrouter);  if (app.get('env') === 'production') {    // in production mode run application dist folder   app.use(express.static(path.join(__dirname, '/../client'))); }  // catch 404 , forward error handler app.use(function(req: express.request, res: express.response, next) {   let err = new error('not found');   next(err); });  // production error handler // no stacktrace leaked user app.use(function(err: any, req: express.request, res: express.response, next: express.nextfunction) {    res.status(err.status || 500);   res.json({     error: {},     message: err.message   }); });  export { app } 

pruduct.ts

 import * mongoose 'mongoose';  interface product{   name: string;   price: number;   count: number; }  interface productmodel extends product, mongoose.document{};  var productshema = new mongoose.schema({   name: string,   price: number,   count: number });  var product = mongoose.model<productmodel>("productlist", productshema);  export = product; 

i have installed node module , typings.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -