简体   繁体   English

如何在Heroku:Python应用程序中设置node_modules目录?

[英]How do I setup a node_modules directory in a Heroku:Python application?

So my python web application needs to use a tool that is built on some node.js tools. 因此,我的python Web应用程序需要使用基于一些node.js工具构建的工具。 Naturally I will place node_modules in my .gitignore and I intend on keeping it that way. 自然地,我将把node_modules放在我的.gitignore ,我打算保持这种方式。 Either way, I need to add another Heroku buildpack, easy. 无论哪种方式,我都需要添加另一个简单的Heroku buildpack。

=== staging-application Buildpack URLs
1. heroku/nodejs
2. heroku/python

I then do a git push staging master but Heroku responds with this 然后,我做一个git push staging master但是Heroku对此回应

App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz

I've searched around for an answer regarding this but haven't gotten very far. 我一直在寻找有关此问题的答案,但距离还很远。 Here are some files that may be of help in the investigation. 以下是一些可能有助于调查的文件。

Here's my procfile 这是我的procfile

# Procfile
web: sh heroku.sh

Here's my heroku script 这是我的heroku脚本

# heroku.sh
cd site

npm install postcss-cli
npm install autoprefixer

gunicorn run:app

As mentioned in " Herokuにデプロイされない! " (It is not deployed in Heroku!) 如“ Herokuにデプロイされない! ”(在Heroku中未部署!)中所述。

rootディレクトリが違った (The root directory is wrong) rootディレクトリが违った(根目录错误)

In that article, Tatiana Yamaguchi mentions pushing the wrong folder as root directory, and said root folder shouls also include a Gemfile . 在那篇文章中, Tatiana Yamaguchi提到将错误的文件夹作为根目录推送,并且说根文件夹还应该包含一个Gemfile

I found that the root directory is one folder above and that pushed objects do not have a Gemfile in the root directory. 我发现根目录在上面的一个文件夹中,并且推送的对象在根目录中没有Gemfile So Heroku did not understand that what was pushed was Ruby. 所以Heroku不明白被推的是Ruby。
So I reworked the local repository again and changed it so that the position where Gemfile is located becomes root. 因此,我再次修改了本地存储库并进行了更改,以使Gemfile所在的位置成为根目录。

That is: like " Managing Gems with Bundler ", where it is recommended to: 也就是说:像“ 用Bundler管理宝石 ”一样,建议:

Create a file named Gemfile in the root of your app specifying what gems are required to run it. 在应用程序的根目录中创建一个名为Gemfile的文件,指定运行该文件需要哪些gem。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM