Я после этого previously asked question, но я получаю эту ошибку:HTML node.js форму ввода
[email protected]:~/Desktop/test/sample$ nodejs smallNode.js /home/usera/Desktop/test/sample/smallNode.js:3 var app = express(); ^ TypeError: object is not a function at Object.<anonymous> (/home/usera/Desktop/test/sample/smallNode.js:3:11) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:902:3
Что мне не хватает?
сервера код сторона:
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
//Note that in version 4 of express, express.bodyParser() was
//deprecated in favor of a separate 'body-parser' module.
app.use(bodyParser.urlencoded({ extended: true }));
//app.use(express.bodyParser());
app.post('/myaction', function(req, res) {
res.send('You sent the name "' + req.body.name + '".');
});
app.listen(8080, function() {
console.log('Server running at http://127.0.0.1:8080/');
});
Вот результаты запуска НПМ установки. Похоже, есть предупреждение в процессе установки, поэтому, возможно, это вопрос ...
[email protected]:~/Desktop/test/sample$ npm install express
npm http GET https://registry.npmjs.org/express/2.5.8
npm http 304 https://registry.npmjs.org/express/2.5.8
npm WARN engine [email protected]: wanted: {"node":">= 0.4.1 < 0.7.0"} (current: {"node":"v0.10.25","npm":"1.3.10"})
npm http GET https://registry.npmjs.org/connect
npm http GET https://registry.npmjs.org/mime/1.2.4
npm http GET https://registry.npmjs.org/qs
npm http GET https://registry.npmjs.org/mkdirp/0.3.0
npm http 304 https://registry.npmjs.org/connect
npm http 304 https://registry.npmjs.org/qs
npm http 304 https://registry.npmjs.org/mime/1.2.4
npm http 304 https://registry.npmjs.org/mkdirp/0.3.0
npm http GET https://registry.npmjs.org/formidable
npm http 304 https://registry.npmjs.org/formidable
[email protected] node_modules/express
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected] ([email protected])
Работает нормально, когда проверяю. – Quentin
Вы 'npm install express'? –
Да, отредактировано оригинальное сообщение, чтобы включить результаты от 'npm install express' –