Cloud Foundry-文件夹结构和相对路径 [英] Cloud Foundry - Folder structure and relative paths

查看:71
本文介绍了Cloud Foundry-文件夹结构和相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与我在IBM Cloud上使用CF遇到的问题有些相关。在解决了文件夹结构后,我的问题是CF相对路径到底是如何构建应用程序的?

This is somewhat related to an issue I'm having with CF on IBM Cloud here. My question after playing around with the folder structures is how exactly is CF building the app when it comes to relative paths?

例如,如果我具有以下文件夹结构

For example, if i have the following folder structure

当我添加< script type ='text / javascript'src ='../ index.js'>< / script> index.html 文件,我得到 GET https://simple-toolchain-20190320022356947.mybluemix.net/index.js net :: ERR_ABORTED 404 。当我将 index.js 移到 public 文件夹并更改<时,不会发生此错误。 ; script type ='text / javascript'src ='index.js'>< / script>

when I add <script type = 'text/javascript' src = '../index.js'></script> to the index.html file, I get GET https://simple-toolchain-20190320022356947.mybluemix.net/index.js net::ERR_ABORTED 404. This error does not happen when I move index.js into the public folder and change <script type = 'text/javascript' src = 'index.js'></script>.

我遇到的问题然后就是当 index.js 文件位于子目录中时,当我尝试 require()任何模块时,它返回一个 Require is not defined 错误,表明它没有从CF为 node_modules 缓存中获取模块。假设要建造。要求同一子目录中的任何文件也会引发相同的错误。当在默认 app.js 中将 require()用作应用程序时,这似乎不是问题。加载时没有任何错误。

The problem I have then is that when I try to require() any modules when the index.js file is in a sub-directory, it returns a Require is not defined error indicating that it is not getting the module from the node_modules cache which CF is suppose to build. Requiring any files in the same sub-directory also throws the same error. This does not seem to be a problem when the require() is used in the default app.js as the application loads without any errors.

我对IBM Cloud Foundry工具比较陌生,但是我遵循的结构与通过Cloud9 IDE推送应用程序时的结构相同,那里没有任何此类问题。我觉得我可能缺少一些简单的东西,例如端点或package.json的配置。但是,我已经搜寻了好几天,似乎找不到解决方法。

I'm relatively new to the IBM Cloud Foundry tool but I'm following the same structure as when I pushed apps via Cloud9 IDE and didn't have any such issues there. I feel I might be missing something ridiculously simple like configuration of endpoint or package.json. However, I've been searching around for days and can't seem to find a solution.

如果有任何指点,不胜感激。谢谢!

Appreciate if you have any pointers. Thanks!

推荐答案

由于缺乏理解,我试图使用 require()在客户端因此错误。现在要弄清楚如何使用Browserify。 ;)

Due to my lack of understanding, I was trying to use require() on the client side hence the errors. Going to figure out how to use Browserify now. ;)

这篇关于Cloud Foundry-文件夹结构和相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆