简体   繁体   English

如何将节点js包添加到Meteor应用程序?

[英]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. 我正在尝试使Express和Multer Node.js包与Meteor 1.7一起使用,但是最后出现错误消息。

I followed this tutorial https://themeteorchef.com/tutorials/using-npm-packages and took the following steps to install Express and Multer packages: 我遵循了本教程https://themeteorchef.com/tutorials/using-npm-packages ,并按照以下步骤安装Express和Multer软件包:

  1. created a new meteor project 创建了一个新的流星项目

  2. ran meteor npm install express multer --save command 运行meteor npm install express multer --save命令

  3. imported the two packages to the app via api.js file (imported to both server and client during dev), which reads: 通过api.js文件(在开发过程中同时导入到服务器和客户端)将这两个软件包导入了应用程序:

     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 TypeError:Express不是函数

and Meteor exits with: 流星退出时:

code 1 ==> Your application is crashing. 代码1 ==>您的应用程序崩溃了。 Waiting for file change. 等待文件更改。

What am I doing wrong? 我究竟做错了什么?

Unsure if you can use express with meteor. 不确定是否可以将Express与流星一起使用。 Meteor has a built in WebApp module which you can use to add custom routing if that is what you are trying to do 流星具有内置的WebApp模块,如果您要这样做,则可以使用它来添加自定义路由

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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