当我尝试部署node.js文件时出现此错误。
Updated failed with Could not triggers. The error was Error: Module body-parser.js not found
这是我的代码:
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.set('views', 'cloud/views');
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded());
app.use(bodyParser.json());
app.get('/hello', function(req, res) {
res.render('hello', { message: 'Congrats, you just set up your app!' });
});
app.listen();
我在本地计算机上安装了npm install body-parser。我应该怎么做才能让Parse识别出这个模块?
答案 0 :(得分:4)
Parse的express框架不是一个完整的node.js应用程序。因此,您无法直接使用Parse不支持的node.js包。 试试这个,
var express = require('express');
var app = express();
app.set('views', 'cloud/views');
app.set('view engine', 'ejs');
app.use(express.json()); // to support JSON-encoded bodies
app.use(express.urlencoded()); // to support URL-encoded bodies
app.get('/hello', function(req, res) {
res.render('hello', { message: 'Congrats, you just set up your app!' });
});
app.listen();