Не удалось найти включаемый файл
У меня простой сервер
var express = require('express')
var app = express()
app.set('view engine', 'ejs');
app.use(express.static('public'))
// home page request handler
app.get('/', function (req, res) {
res.render('home')
})
// initializes request listener
app.listen(process.env.PORT, process.env.IP, function(){
console.log("Server is listening");
})
Когда я делаю GET-запрос 9X_node.js для домашней страницы, во время выполнения 9X_embedded-javascript выдается следующая ошибка
Error: Could not find include include file.
at getIncludePath (/home/ubuntu/workspace/node_modules/ejs/lib/ejs.js:152:13)
at includeSource (/home/ubuntu/workspace/node_modules/ejs/lib/ejs.js:276:17)
at /home/ubuntu/workspace/node_modules/ejs/lib/ejs.js:629:26
at Array.forEach (native)
at Object.generateSource (/home/ubuntu/workspace/node_modules/ejs/lib/ejs.js:605:15)
at Object.compile (/home/ubuntu/workspace/node_modules/ejs/lib/ejs.js:509:12)
at Object.compile (/home/ubuntu/workspace/node_modules/ejs/lib/ejs.js:358:16)
at handleCache (/home/ubuntu/workspace/node_modules/ejs/lib/ejs.js:201:18)
at tryHandleCache (/home/ubuntu/workspace/node_modules/ejs/lib/ejs.js:223:14)
at View.exports.renderFile [as engine] (/home/ubuntu/workspace/node_modules/ejs/lib/ejs.js:437:10)
Я не понимаю эту 9X_javascript-library ошибку. Любые идеи? Я работаю в Cloud9.
Моя 9X_.js структура каталогов
v1.1
+---views
| +---- home.ejs
| +---- partials
| +------ header.ejs
| +------ footer.ejs
|
+----app.js
home.ejs
<% include header %>
welcome
<% include footer %>
header.ejs
footer.ejs
- `<% include partials / footer%>`<p><s ...
Ответ #1
Ответ на вопрос: Не удалось найти включаемый файл
Пути включения являются относительными, вам 9X_ejs нужно будет обновить их, чтобы включить 9X_javascript-library подпапку "partials", например
<% include partials/header %>
welcome
<% include partials/footer %>
См. docs
Ответ #2
Ответ на вопрос: Не удалось найти включаемый файл
Попробуйте любое из этих:
<% include header.ejs %>
<% include header %>
<%- include('header.ejs'); -%>
<%- include('./header.ejs'); -%>
9X_vanillajs
Ответ #3
Ответ на вопрос: Не удалось найти включаемый файл
Мне пришлось установить корневой параметр,
ejs.render(
html,
{},
{
root: process.cwd(),
}
)
А 9X_cloud9 затем используйте это как,
<%- include('/footer/index.ejs'); %>
-
1
-
2
-
2
-
5
-
12
-
4
-
1
-
4
-
7
-
1
-
5
-
3
-
2
-
3
-
6
-
2
-
6
-
2
-
4
-
3
-
2
-
1
-
2
-
4
-
4
-
2
-
10
-
8
-
26
-
1
-
6
-
3
-
4
-
4
-
2
-
6
-
4
-
2
-
1
-
1
-
2
-
4
-
2
-
2
-
2
-
5
-
3
-
11
-
1
-
4