Heroku上的Clojure + Clojurescript应用程序:部署应用程序时未安装npm软件包的依赖项

马马肯齐

我正在使用Clojure的后端和使用React和Reagent的Clojurescript前端编写一个Web应用程序。我正在尝试将其托管在Heroku上。

当我在lein ubjerar本地运行时,它可以正常运行并且该应用程序可以运行。

但是,当我尝试通过将应用程序部署到Heroku时git push heroku master,总是会遇到如下错误:

remote:        Preparing npm packages
remote:        Installing npm packages
remote:        npm packages successfully installed
remote:        Running shadow-cljs...
remote:        [:app] Compiling ...
remote:        The required JS dependency "object-assign" is not available, it was required by "node_modules/react/cjs/react.production.min.js".
remote:
remote:        Searched in:/tmp/build_c09494ebe081fa0581db343dc809fb45/node_modules
remote:
remote:        You probably need to run:
remote:          npm install object-assign
remote:
remote:        See: https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install
remote:
remote:  !     Failed to build.
remote:  !     Push rejected, failed to compile Clojure (Leiningen 2) app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !   Push rejected to getfluentspanish.
remote:
To https://git.heroku.com/getfluentspanish.git
 ! [remote rejected] master -> master (pre-receive hook declined)

出现这种情况,尽管这一事实object-assign被列为的依赖reactNPM包,我已经列为项:npm-deps在我的project.clj我已经验证,当我在本地构建时,该软件包可以很好地安装(即在这种情况下node_modules/object-assign存在)。

当我在中手动添加object-assign为显式依赖项时:npm-deps,出现相同的错误,但抱怨应该自动安装(并本地安装)其他缺少的依赖项当我添加新的缺少的依赖项时,它会抱怨另一个。当我在本地使用新的显式依赖进行构建时,可以工作,但抱怨现在存在版本冲突,因为隐式依赖通常固定在其他版本上。lein uberjar

知道我该如何解决吗?

编辑这是我的project.clj

(defproject getfluentspanish "0.1.0-SNAPSHOT"

  :description "FIXME: write description"
  :url "http://example.com/FIXME"

  :dependencies [[cheshire "5.8.1"]
                 [cljs-ajax "0.8.0"]
                 [clojure.java-time "0.3.2"]
                 [com.cognitect/transit-clj "0.8.313"]
                 [com.google.javascript/closure-compiler-unshaded "v20190528" :scope "provided"]
                 [cprop "0.1.13"]
                 [day8.re-frame/http-fx "0.1.6"]
                 [funcool/struct "1.4.0"]
                 [luminus-immutant "0.2.5"]
                 [luminus-transit "0.1.1"]
                 [markdown-clj "1.10.0"]
                 [metosin/muuntaja "0.6.4"]
                 [metosin/reitit "0.3.7"]
                 [metosin/ring-http-response "0.9.1"]
                 [mount "0.1.16"]
                 [nrepl "0.6.0"]
                 [org.clojure/clojure "1.10.1"]
                 [org.clojure/clojurescript "1.10.520" :scope "provided"]
                 [org.clojure/google-closure-library "0.0-20190213-2033d5d9" :scope "provided"]
                 [org.clojure/tools.cli "0.4.2"]
                 [org.clojure/tools.logging "0.4.1"]
                 [org.webjars.npm/bulma "0.7.5"]
                 [org.webjars.npm/material-icons "0.3.0"]
                 [org.webjars/webjars-locator "0.36"]
                 [org.webjars/webjars-locator-jboss-vfs "0.1.0"]
                 [re-frame "0.10.6"]
                 [reagent "0.8.1"]
                 [ring-webjars "0.2.0"]
                 [ring/ring-core "1.7.1"]
                 [ring/ring-defaults "0.3.2"]
                 [selmer "1.12.12"]
                 [thheller/shadow-cljs "2.8.39" :scope "provided"]]

  :min-lein-version "2.0.0"

  :source-paths ["src/clj" "src/cljs" "src/cljc"]
  :test-paths ["test/clj"]
  :resource-paths ["resources" "target/cljsbuild"]
  :target-path "target/%s/"
  :main ^:skip-aot getfluentspanish.core

  :plugins [[lein-shadow "0.1.3"]
            [lein-immutant "2.1.0"]
            [lein-sassc "0.10.4"]
            [lein-auto "0.1.2"]]
   :sassc
   [{:src "resources/scss/screen.scss"
     :output-to "resources/public/css/screen.css"
     :style "nested"
     :import-path "resources/scss"}] 

   :auto
   {"sassc" {:file-pattern #"\.(scss|sass)$" :paths ["resources/scss"]}} 

  :hooks [leiningen.sassc]
  :clean-targets ^{:protect false}
  [:target-path "target/cljsbuild"]
  :shadow-cljs
  {:nrepl {:port 7002}
   :builds
   {:app
    {:target :browser
     :output-dir "target/cljsbuild/public/js"
     :asset-path "/js"
     :modules {:app {:entries [getfluentspanish.app]}}
     :devtools {:watch-dir "resources/public"}}
    :test
    {:target :node-test
     :output-to "target/test/test.js"
     :autorun true}}}

  :npm-deps [[core-js "^2.6.9"]
             [shadow-cljs "2.8.31"]
             [create-react-class "15.6.3"]
             [react "16.8.6"]
             [react-dom "16.8.6"]
             [react-beautiful-dnd "11.0.4"]
             [react-dnd "7.6.0"]
             [react-dnd-html5-backend "7.6.0"]
             [react-dnd-touch-backend "0.8.3"]
             [react-dnd-multi-backend "3.2.1"]]

  :profiles
  {:uberjar {:omit-source true
             :prep-tasks ["compile" ["shadow" "release" "app"]]

             :aot :all
             :uberjar-name "getfluentspanish.jar"
             :source-paths ["env/prod/clj" "env/prod/cljs"]
             :resource-paths ["env/prod/resources"]}

   :dev           [:project/dev :profiles/dev]
   :test          [:project/dev :project/test :profiles/test]

   :project/dev  {:jvm-opts ["-Dconf=dev-config.edn"]
                  :dependencies [[binaryage/devtools "0.9.10"]
                                 [cider/piggieback "0.4.1"]
                                 [expound "0.7.2"]
                                 [pjstadig/humane-test-output "0.9.0"]
                                 [prone "1.6.3"]
                                 [re-frisk "0.5.4.1"]
                                 [ring/ring-devel "1.7.1"]
                                 [ring/ring-mock "0.4.0"]]
                  :plugins      [[com.jakemccrary/lein-test-refresh "0.24.1"]]


                  :source-paths ["env/dev/clj" "env/dev/cljs" "test/cljs"]
                  :resource-paths ["env/dev/resources"]
                  :repl-options {:init-ns user}
                  :injections [(require 'pjstadig.humane-test-output)
                               (pjstadig.humane-test-output/activate!)]}
   :project/test {:jvm-opts ["-Dconf=test-config.edn"]
                  :resource-paths ["env/test/resources"]}



   :profiles/dev {}
   :profiles/test {}})

编辑2我最终放弃了git push heroku master部署方法,转而使用Docker。我在下面的答案中详细介绍了该过程。

马马肯齐

我最终放弃了基于Git的Heroku部署,而是对其进行了重新设计以改为使用Docker。现在,它的工作原理,但唯一的缺点是,我现在我要部署每一次,这是慢于在本地建设一个新码头工人的图像git push heroku master,然后lein uberjar在遥控器上。不过,我可以将此步骤移至CI服务器或其他设备上,并通过Github挂钩进行构建和部署,从而为我提供了类似的便利。

实际上,使用Docker的简单性给我留下了深刻的印象。Dockerfile我使用的是非常简单的:

FROM openjdk:8-alpine
COPY target/uberjar/getfluentspanish.jar /getfluentspanish/app.jar
EXPOSE 3000
CMD ["java", "-jar", "/getfluentspanish/app.jar"]

我希望这对尝试将全栈Clojure&Clojurescript应用程序部署到Heroku的人有所帮助。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

尝试npm运行迁移以部署我的应用程序时在heroku上出错

如何使用`dep`将带有内部软件包的Go应用程序部署到Heroku

在Heroku上未通过Godep安装Go应用程序的依赖项

应用程序在LogCat上显示软件包名称和类,而不是SQLiteDatabase内容

尝试在Heroku上部署Node.js / Express / Socket.io应用程序时出现应用程序错误

在Heroku上部署Fb应用程序

在Heroku上部署MEAN应用程序时出现应用程序错误

Heroku Twitter API应用程序部署

Java Web应用程序部署Heroku

依赖项安装失败!laravel应用程序部署到heroku时出错

在部署现代应用程序时出现Heroku错误

在设备上安装应用程序时出错

Springboot应用程序未部署在Wildfly上

用于在Heroku上部署的破折号应用程序依赖项

部署Dash应用程序时出现Heroku应用程序错误:“ OSError:xlwings需要安装Excel,因此仅适用于Windows和macOS。”

在Android 2.3设备上安装应用程序时出错

如果我在dmg应用程序/软件安装程序上安装软件/应用程序会怎样?

如何在ubuntu 18.04上安装需要gksu软件包的应用程序?

在Unity上的KDE应用程序中应安装哪些软件包来缺少按钮图标?

Rails应用程序未部署到heroku(应用程序错误消息)

在Heroku PHP会话上重新部署应用程序时消失

Heroku部署应用程序错误

无法在Heroku Web应用程序上安装hashlib

在heroku上使用pgsql部署laravel php应用程序

Heroku 上的 Angular 应用程序部署问题

在 Heroku 上加载应用程序依赖项时出现问题

在 Heroku 应用程序上,如何在 Ruby 服务器中安装 Python pip 依赖项?

在具有本地依赖项的 Heroku 上部署 Flask 应用程序

在heroku上部署的django rest框架应用程序上的应用程序错误