我在 Node.js 中制作了一个应用程序,然后在可执行文件中制作了它,但可执行文件仅包含 Node.js 文件,但它给出了错误,即找不到您的 ejs 文件。
Error: Cannot find module 'ejs'
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call.
我正在用命令行让它可执行
pkg -t node6-win entry.js
有人能帮帮我吗? 我什至可以共享 zip 文件。
{
"name": "project_along_voice-mongo",
"version": "1.0.0",
"description": "Chatbot",
"main": "server.js",
"bin": "server.js",
"scripts": {
"build=package":"pkg package.json",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"keywords": [
"chatbot"
],
"assets" : ["plugins/*"],
"author": "wurth",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.3",
"ejs": "^1.0.0",
"express": "^4.16.3",
"mitsobox": "0.1.4",
"mongo": "^0.1.0",
"mongod": "^2.0.0",
"mongodb": "^3.1.1",
"nodemon": "^1.18.3"
},
"pkg": {
"assets" : [
"views/*",
"public/*"
],
"target" : [ "node8"]
}
}
文件夹结构
最佳答案
需要将 Node 模块捆绑在此处的可执行文件中。 您需要在 package.json 文件中添加脚本和 Assets ,并使用通过 package.json 构建的选项。
"pkg": {
"scripts": "node_modules/**/*.js",
"assets": "views/**/*"
}
关于javascript - Node.js 可执行文件不包含我的前端技术,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51593543/