简体   繁体   中英

How to add node js packages to Meteor app?

I am trying to get Express and Multer Node.js packages to work with Meteor 1.7, but I am ending up with error messages.

I followed this tutorial https://themeteorchef.com/tutorials/using-npm-packages and took the following steps to install Express and Multer packages:

  1. created a new meteor project

  2. ran meteor npm install express multer --save command

  3. imported the two packages to the app via api.js file (imported to both server and client during dev), which reads:

     import { Meteor } from 'meteor/meteor'; import multer from 'multer'; import express from 'express'; const app = express(); app.use(function (req, res, next) { console.log('Time:', Date.now()) next() }); 
  4. In the system console, I get the following error:

TypeError: express is not a function

and Meteor exits with:

code 1 ==> Your application is crashing. Waiting for file change.

What am I doing wrong?

Unsure if you can use express with meteor. Meteor has a built in WebApp module which you can use to add custom routing if that is what you are trying to do

https://docs.meteor.com/packages/webapp.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM