Sau*_*ari 6 localhost httpserver angularjs
我已经在节点环境中创建了一个基本的AngularJS应用。我正在使用http-server模块将文件提供给浏览器。一切正常,除了index.html
服务器启动时默认无法提供服务的事实。
我检查了npm注册表以获得http服务器模块的更多选项,还尝试在SO上寻找相关问题,但仍然无法获得我想要的东西。
是否可以指定服务器启动时要拾取的文件。
我的服务器基本上在localhost:8080
我想要的时候开始localhost:8080/index.html
我的开始脚本是http-server -a localhost -p 8080 -c-1
。如果我做这样的事http-server -a localhost -p 8080 -c-1 index.html
,令我惊讶的是它打开了index.html
文件,但是是在文件协议而不是在文件协议上提供的localhost
。
我在这里做错了。
PS我参观了Angular JS种子,那里有官方的例子http-server -a localhost -p 8080 -c-1 ./app
。但是,当我这样做时,我收到错误消息,尽管我的结构类似于种子,但Windows无法找到指定的路径。
我的结构:
dir
--app.js
--index.html
--node_modules
--package.json
Run Code Online (Sandbox Code Playgroud)
确保首先构建项目并生成输出./dist
文件夹或类似文件夹。
然后试试这个命令:
http-server -p 8080 ./dist -o http://localhost:8080/index.html
Run Code Online (Sandbox Code Playgroud)
您http://
的网址中缺少。
PPB*_*PPB -1
尝试将静态文件放入新目录 public 中。并运行你的服务器http-server
- app.js
-public
--index.html
-package.json
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4373 次 |
最近记录: |