[英]Problems with public directory when deploying Node.js app with Heroku
I've been working on an app which will feature a Timelinejs (open source js library) element on the client side. 我一直在开发一个应用程序,它将在客户端提供Timelinejs(开源js库)元素。 I copied the Timelinejs library into my public/javascripts/ directory of my app. 我将Timelinejs库复制到我的应用程序的public / javascripts /目录中。 Then I linked it in my html header. 然后我在我的html标题中链接它。 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. 但是,我注意到当我将我的应用程序部署到Heroku时,它没有加载我的时间线。 Using chrome js console I discovered that it didn't find my files in the public/Javascripts/Timelinejs folder. 使用chrome js控制台我发现它没有在public / Javascripts / Timelinejs文件夹中找到我的文件。 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. 使用Heroku run bash命令,我发现文件结构中没有任何Timelinejs文件,尽管存在空的Timelinejs目录。 Is there any command or configuration I need to specify to get these files to my Heroku deployment? 是否需要指定任何命令或配置才能将这些文件提供给我的Heroku部署?
Heroku has a readonly file system. Heroku有一个只读文件系统。 The directory where you can write are ./tmp or ./log. 您可以编写的目录是./tmp或./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. 如果要存储内容,请使用./tmp或推荐的s3存储桶。 (as I presume 'tmp' stands for 'temporary' :D) (因为我认为'tmp'代表'临时':D)
More info here: https://devcenter.heroku.com/articles/read-only-filesystem 更多信息: https : //devcenter.heroku.com/articles/read-only-filesystem
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.