使用Heroku部署Node.js应用程序时公共目录出现问题

问题描述:

我一直在开发一个在客户端具有Timelinejs(开源js库)元素的应用程序.我将Timelinejs库复制到应用程序的public/javascripts/目录中.然后,将其链接到我的html标头中.当我在本地提供我的应用程序时,所有时间轴都可以正常运行.但是,我注意到,当我将应用程序部署到Heroku时,并没有加载我的时间表.使用chrome js控制台,我发现它没有在public/Javascripts/Timelinejs文件夹中找到我的文件.使用Heroku run bash命令,我发现文件结构中不存在我的Timelinejs文件,尽管存在一个空的Timelinejs目录.我需要指定任何命令或配置来将这些文件添加到我的Heroku部署中吗?

I've been working on an app which will feature a Timelinejs (open source js library) element on the client side. I copied the Timelinejs library into my public/javascripts/ directory of my app. Then I linked it in my html header. When I serve my app up locally everything works fine with the timeline. However, I noticed that when I deployed my app to Heroku it wasn't loading my timeline. Using chrome js console I discovered that it didn't find my files in the public/Javascripts/Timelinejs folder. Using the Heroku run bash command I discovered that none of my Timelinejs files were present in the file structure, although an empty Timelinejs directory was present. Is there any command or configuration I need to specify to get these files to my Heroku deployment?

Heroku具有只读文件系统.可以写入的目录是./tmp或./log.您不能在公用文件夹内写入. 这是因为他们如何处理测功和扩展测功的方法.如果要存储某些内容,请使用./tmp或建议使用s3存储桶. (因为我假设'tmp'代表'temporary':D)

Heroku has a readonly file system. The directory where you can write are ./tmp or ./log. You can't write inside the public folder. That's because of how they manage their dynos and the way to scale them. If you want to store something, use the ./tmp or, recommended, a s3 bucket. (as I presume 'tmp' stands for 'temporary' :D)

此处的更多信息: https://devcenter.heroku.com/articles/read-唯一文件系统