Angularjs 从elastic beanstalk服务静态文件不工作
我有一个angular应用程序,它在localhost上运行得非常好,但在beanstalk上它并没有为我所有的文件提供服务。只有我的index.html和styles.css被找到并提供,它们都在我的根目录中的一个名为public的文件夹中。 我的构建文件位于路径/build/build.js中,它不会提供服务,但在本地主机上会提供服务 我目前只是从我的服务器提供文件,没有使用staticfiles.config,因为这完全不起作用 文件夹结构:Angularjs 从elastic beanstalk服务静态文件不工作,angularjs,node.js,amazon-web-services,amazon-ec2,Angularjs,Node.js,Amazon Web Services,Amazon Ec2,我有一个angular应用程序,它在localhost上运行得非常好,但在beanstalk上它并没有为我所有的文件提供服务。只有我的index.html和styles.css被找到并提供,它们都在我的根目录中的一个名为public的文件夹中。 我的构建文件位于路径/build/build.js中,它不会提供服务,但在本地主机上会提供服务 我目前只是从我的服务器提供文件,没有使用staticfiles.config,因为这完全不起作用 文件夹结构: root: /public : index
root:
/public : index.html ,styles.css
/src: modularized angular and htmls for routes .
/build: build.js
const express=require('express');
const path=require('path');
常数fs=要求('fs');
const bodyParser=require('body-parser');
const emailController=require('./控制器/emailController');
常量app=express();
const port=process.env.port | 3000;
use(bodyParser.json());
app.use(express.static(path.resolve(uu dirname,../public));
app.use(express.static(path.resolve(uu dirname,“../”));
app.post('/email',emailController);
应用程序侦听(端口,()=>{
log(`Server正在监听mfing${port}`);
});代码>
水合包和冷却器袋|绝对零
将脚本搜索替换为以下内容。您需要使用/
<script src="./node_modules/angular/angular.js"></script>
<script src="./node_modules/angular-route/angular-route.js"></script>
<script src="./build/build.js"></script>
将脚本搜索替换为以下内容。您需要使用/
<script src="./node_modules/angular/angular.js"></script>
<script src="./node_modules/angular-route/angular-route.js"></script>
<script src="./build/build.js"></script>
不起作用。当我把我的构建放在我的公共文件夹中并使用./build.js时,它可以很好地工作,而不用把./。我也试过../build/build.js,但它不起作用。你能把这些文件也放到公用文件夹里吗?或者只要copy-paste
将它们粘贴到脚本标记中,如果它们不太长的话?或者您可以将它们上传到扩展名为.js
的网站,并将链接置于src
属性中。我向你展示了三种方式,给你!=)@奇怪的是我的角度文件被提供了但我的构建文件不是所以现在是你的构建文件@然后,JiniHendrix将该文件从public
dir中取出,放在angulars旁边。:)出于某种原因,它似乎不会提供名为build的文件夹中的文件。我把它改成了“buildy”,效果很好。奇怪的东西,没用。当我把我的构建放在我的公共文件夹中并使用./build.js时,它可以很好地工作,而不用把./。我也试过../build/build.js,但它不起作用。你能把这些文件也放到公用文件夹里吗?或者只要copy-paste
将它们粘贴到脚本标记中,如果它们不太长的话?或者您可以将它们上传到扩展名为.js
的网站,并将链接置于src
属性中。我向你展示了三种方式,给你!=)@奇怪的是我的角度文件被提供了但我的构建文件不是所以现在是你的构建文件@然后,JiniHendrix将该文件从public
dir中取出,放在angulars旁边。:)出于某种原因,它似乎不会提供名为build的文件夹中的文件。我把它改成了“buildy”,效果很好。奇怪的东西。