1

So we have a node.js solution with 3 projects on the same repository on a private GitLab instance.

  • 1st -> A Node.js web app that we deploy to a 1st Heroku by ci/cd
  • 2nd -> Another Node.js API that we deploy to 2nd Heroku by ci/cd
  • 3rd -> A package commonly used by 1st and 2nd package which we want to deploy with both of them

So we npm link the 3rd package with both the first one and the second one.

When we had only the first and second packages, deployment was fine and we didn't have any problem.

Note: We use DPL to do the deployment on Heroku

dpl --provider=heroku --app=$HEROKU_WEB --api-key=$HEROKU_API_KEY --skip_cleanup

But then we triggered deployment of the 3 packages and the deployment fail :

Installing dependencies
   Installing node modules
   npm ERR! code EEXIST
   npm ERR! syscall mkdir
   npm ERR! path /tmp/build_4b93de5e/node_modules/ai-validator
   npm ERR! errno -17
   npm ERR! EEXIST: file already exists, mkdir '/tmp/build_4b93de5e/node_modules/ai-validator'
   npm ERR! File exists: /tmp/build_4b93de5e/node_modules/ai-validator
   npm ERR! Remove the existing file and try again, or run npm
   npm ERR! with --force to overwrite files recklessly.
   
   npm ERR! A complete log of this run can be found in:
   npm ERR!     /tmp/npmcache.BtRYQ/_logs/2020-12-18T09_45_42_167Z-debug.log
-----> Build failed

According to the logs, we have to use npm install --force but on Heroku, we don't have a hand on this.

From there, I've looked up several solutions, I found things about symlinks going wrongs with git but that seems to be solved now within git.

I've mainly found that it isn't possible and that you have to host your package somewhere like npm so it can be found by the Heroku npm install. This solution isn't available for us, as we're not allowed to do so.

It could also be DPL but to be honest I don't know what I can do with that.

So I'm kind of stuck there.

Any idea?

0

1 Answer 1

1

I have encountered the same issue and I have found it to be a problem with their GitHub deployment method, for some reason, at least in my case.

I have since switched to their Heroku CLI and it recognized the submodule correctly and was able to deploy the app.

To give some perspective; my structure looks like this:

front-end (react app) is used to build the app, back-end (express) serves the production build and is the API server. Heroku first runs react-scripts build on front-end to build the production build, and then runs node ./back-end/main.js

front-end is my top-level repo and back-end is my sub-module

front-end/
front-end/back-end (git submodule)

Assuming your sub-module is also an npm package I had to add my back-end folder as a dependency for front-end in package.json. This makes it so your submodule package is properly recognized as a dependency and its dependant packages also get downloaded via npm (they will get stored in front-end .node-modules, not back-end)

"dependencies": {
    [...]
    "back-end": "file:back-end", // This points to ./backend
    [...]
}

My Procfile is located in the top-most package (front-end) and it looks like this:

web: node ./backend/main.js

Not sure if my answer will contribute to anything, but in a big nutshell: GitHub deployment didn't work for me, but using their CLI tool and hosting it on their git did work. It might not be a user issue.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your complete answer ! I'll try out this monday and will get back to you :)
So I tried but it didn't really helped me. I finally deployed the package using gitlab private package registry and then I deploy the main package using npmrc registries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.