我有以下问题。
我使用 ember-cli 创建了一个 ember 应用程序。
当运行命令 ember serve
时,应用程序通过 url http://localhost:4200/
在 nodejs 上运行良好
我想在 apache httpd 服务器上部署这个应用程序。
为了让它工作,我认为它在 firefox 中打开时也应该独立工作。
当我在 firefox 中打开它时出现错误:
require is not defined
生成的index.html是
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Foo</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no">
<base href="/" />
<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/foo.css">
</head>
<body>
<script>
window.FooENV = {"environment":"development","baseURL":"/","locationType":"auto","EmberENV":{"FEATURES":{}},"APP":{"LOG_RESOLVER":true,"LOG_ACTIVE_GENERATION":true,"LOG_MODULE_RESOLVER":true,"LOG_VIEW_LOOKUPS":true},"LOG_MODULE_RESOLVER":true};
window.EmberENV = window.FooENV.EmberENV;
</script>
<script src="assets/vendor.js"></script>
<script src="assets/foo.js"></script>
<script>
window.Foo = require('foo/app')['default'].create(FooENV.APP);
</script>
</body>
</html>
我该如何解决这个问题?
谢谢,
大卫
最佳答案
file:///J:/assets/ndd.css
在我看来,您只是双击了 dist 文件夹中的 index.html 文件。这行不通!
您必须通过 http 服务器提供您的目录。
使用 npm 安装一个简单的 http 服务器:
npm install -g http-server
移动到您的 dist 文件夹并运行 http-server
。您将看到这样的消息:
Starting up http-server, serving ./ on port: 8080
现在您可以在 Firefox 中检查您的 ember 应用:http://localhost:8080
关于ember.js - 如何在 apache 服务器中部署 ember-cli 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24782035/