Deploying Phoenix app to gigalixir: Deploy aborted - mkdir: cannot create directory ‘node_modules’: File exists

Hey, am deploying my phoenix app to Gigalixir for the first time and am getting the error

$ git push gigalixir master
Enumerating objects: 19536, done.
Counting objects: 100% (19536/19536), done.
Delta compression using up to 2 threads
Compressing objects: 100% (13906/13906), done.
Writing objects: 100% (19493/19493), 37.69 MiB | 73.79 MiB/s, done.
Total 19493 (delta 7223), reused 16924 (delta 4679), pack-reused 0
remote: Resolving deltas: 100% (7223/7223), completed with 18 local objects.
remote: Starting deploy
remote: Preparing cache
remote: Compiling code and generating slug.
remote: Setting environment variables.
remote: * LIBCLUSTER_KUBERNETES_SELECTOR
remote: * LIBCLUSTER_KUBERNETES_NODE_BASENAME
remote: * APP_NAME
remote: * SECRET_KEY_BASE
remote: * PORT
remote: * SOURCE_VERSION
remote: * POOL_SIZE
remote: * DATABASE_URL
remote:        ----->        Found custom phoenix_static_buildpack.config
remote:        Detecting assets directory
remote:        package.json found in assets directory
remote:        Elixir+Phoenix+Distillery+Releases app detected
remote:        Found custom phoenix_static_buildpack.config
remote:        Detecting assets directory
remote:        package.json found in assets directory
remote: =====> Downloading Buildpack: https://github.com/HashNuke/heroku-buildpack-elixir.git
remote: =====> Detected Framework: Elixir
remote: -----> Will export the following config vars:
remote:        APP_NAME
remote:        DATABASE_URL
remote:        LIBCLUSTER_KUBERNETES_NODE_BASENAME
remote:        LIBCLUSTER_KUBERNETES_SELECTOR
remote:        POOL_SIZE
remote:        PORT
remote:        SECRET_KEY_BASE
remote:        SOURCE_VERSION
remote:        * MIX_ENV=prod
remote: -----> Checking Erlang and Elixir versions
remote:        Will use the following versions:
remote:        * Stack heroku-20
remote:        * Erlang 24.0
remote:        * Elixir v1.13.4
remote: -----> Using cached Erlang 24.0
remote: -----> Installing Erlang 24.0
remote: 
remote: -----> Using cached Elixir v1.13.4
remote: -----> Installing Elixir v1.13.4
remote: -----> Installing Hex
remote:        * creating /tmp/build/.mix/archives/hex-2.0.6
remote: -----> Installing rebar
remote:        * creating /tmp/build/.mix/rebar
remote:        * creating /tmp/build/.mix/rebar3
remote: -----> Fetching app dependencies with mix
remote:        Resolving Hex dependencies...
remote:        Resolution completed in 0.331s
remote:        Unchanged:
remote:        bamboo 1.6.0
remote:        bamboo_smtp 2.1.0
remote:        calendar 0.17.6
remote:        certifi 2.9.0
remote:        combine 0.10.0
remote:        connection 1.1.0
remote:        cowboy 2.9.0
remote:        cowboy_telemetry 0.3.1
remote:        cowlib 2.11.0
remote:        db_connection 2.4.3
remote:        decimal 2.0.0
remote:        ecto 3.9.2
remote:        ecto_sql 3.9.1
remote:        endon 1.0.6
remote:        gen_smtp 0.15.0
remote:        gettext 0.20.0
remote:        hackney 1.18.1
remote:        html_entities 0.5.2
remote:        httpoison 0.13.0
remote:        idna 6.1.1
remote:        jason 1.4.0
remote:        metrics 1.0.1
remote:        mime 2.0.3
remote:        mimerl 1.2.0
remote:        parse_trans 3.3.1
remote:        phoenix 1.5.14
remote:        phoenix_ecto 4.4.0
remote:        phoenix_html 2.14.3
remote:        phoenix_live_dashboard 0.4.0
remote:        phoenix_live_view 0.15.7
remote:        phoenix_pubsub 2.1.1
remote:        plug 1.14.0
remote:        plug_cowboy 2.6.0
remote:        plug_crypto 1.2.3
remote:        postgrex 0.16.5
remote:        ranch 1.8.0
remote:        sneeze 1.2.1
remote:        ssl_verify_fun 1.1.6
remote:        sweet_xml 0.6.6
remote:        telemetry 0.4.3
remote:        telemetry_metrics 0.6.1
remote:        telemetry_poller 0.5.1
remote:        textex 0.2.2
remote:        timex 3.7.9
remote:        tzdata 1.1.1
remote:        unicode_util_compat 0.7.0
remote:        * Getting postgrex (Hex package)
remote: -----> Copying hex from /tmp/build/.hex
remote: -----> Compiling
remote: ==> postgrex
remote:        Compiling 64 files (.ex)
remote:        Generated postgrex app
remote: ==> ecto_sql
remote:        Compiling 25 files (.ex)
remote:        Generated ecto_sql app
remote: ==> schmsy
remote:        Compiling 55 files (.ex)
remote:        Compiling lib/schmsy_web/views/administration_view.ex (it's taking more than 10s)
remote:        Generated schmsy app
remote:        * Cleaning tds
remote: -----> Creating .profile.d with env vars
remote: -----> Writing export for multi-buildpack support
remote: =====> Downloading Buildpack: https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
remote: =====> Detected Framework: Phoenix
remote:
remote: -----> Loading configuration and environment
remote:        Loading config...
remote:        Detecting assets directory
remote:        WARNING: no package.json detected in root nor custom directory
remote:        * assuming phoenix 1.3.x and later, please check config file
remote:        Will use phoenix configuration:
remote:        * assets path assets
remote:        * mix tasks namespace phx
remote:        Will use the following versions:
remote:        * Node 12.16.3
remote:        Will export the following config vars:
remote:        APP_NAME
remote:        DATABASE_URL
remote:        LIBCLUSTER_KUBERNETES_NODE_BASENAME
remote:        LIBCLUSTER_KUBERNETES_SELECTOR
remote:        POOL_SIZE
remote:        PORT
remote:        SECRET_KEY_BASE
remote:        SOURCE_VERSION
remote:        * MIX_ENV=prod
remote:
remote: -----> Installing binaries
remote:        Using cached node 12.16.3...
remote:        Installing Node 12.16.3...
remote:        Using default npm version 6.14.4
remote:
remote: -----> Building dependencies
remote:        Loading node modules from cache
remote: mkdir: cannot create directory ‘node_modules’: File exists
remote: 2023/04/27 14:56:54 exit status 1
remote: Deploy aborted
To https://git.gigalixir.com/schmsy.git/
 ! [remote rejected]   master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.gigalixir.com/schmsy.git/'

what could be the problem?

1 Like

Did you, maybe, by accident, add assets/node_modules directory to Git?

Generally, it shouldn’t be commited to repository, and you should remove it, make a commit, and then add the directory to .gitignore so that it won’t happen again.

2 Likes

Thanks @hubertlepicki it has worked.

1 Like