【发布时间】:2018-03-28 07:08:31
【问题描述】:
您好,我刚开始编程,我开始在 heroku 中制作我的简单作品集 问题是子页面我不知道如何将新的子页面添加到我的投资组合中我总是无法获取 /frontend.ejs
链接到我的投资组合: http://poninsky.herokuapp.com
我没有太多关于node js的知识
这是来自 index.js 的代码,我从 heroku 得到什么我需要 chenge 来添加子页面:
var express = require('express');
var app = express();
app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/public'));
// views is directory for all template files
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.get('/', function(request, response) {
response.render('pages/index');
});
app.get('/frontend', function(request, response) {
response.render('pages/frontend');
});
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
感谢您的回答!
运行后我得到这个:
module.js:471
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/root/Desktop/test/node-js-getting-started
/index.js:1:77)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! Linux 4.12.0-kali1-amd64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run-script" "start"
npm ERR! node v6.11.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! node-js-getting-started@0.2.6 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-js-getting-started@0.2.6 start script 'node
index.js'.
npm ERR! Make sure you have the latest version of node.js and npm
installed.
npm ERR! If you do, this is most likely a problem with the node-js-
getting-started package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index.js
npm ERR! You can get information on how to open an issue for this project
with:
npm ERR! npm bugs node-js-getting-started
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls node-js-getting-started
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean
to install? '
npm ERR! Please include the following file with any support request:
npm ERR! /root/Desktop/test/node-js-getting-started/npm-debug.log
Done.
【问题讨论】:
-
Error: Cannot find module 'express'?先试试npm install -
嘿,当我输入 npm install 我得到这个答案:npm WARN node-js-getting-started@0.2.6 No repository field.
-
没关系......这意味着你没有在你的package.json中指定一些文件。尝试运行应用程序。
标签: javascript html css node.js heroku