Combining Express 4 and Vue CLI 32019 Community Moderator ElectionHow do I install package.json dependencies in the current directory using npmCannot run index.js in nodejs with expressWhy use peer dependencies in npm for plugins?Error while installing vue-clivue-cli v3 with node.js firebase functions, firebase hosting (Error: No npm package found in functions source directory)problems with vue-cli for productionVue-cli-3 with EQCSSComponent(.vue file) editable build with vue cli 3Why when i create a vue project with 'vue-cli' fail?Vue CLI Child compilation failed after first build unless I clear .cache folder

How does Ehrenfest's theorem apply to the quantum harmonic oscillator?

Specifying a starting column with colortbl package and xcolor

Recommendation letter by significant other if you worked with them professionally?

After `ssh` without `-X` to a machine, is it possible to change `$DISPLAY` to make it work like `ssh -X`?

Is it possible that a question has only two answers?

I reported the illegal activity of my boss to his boss. My boss found out. Now I am being punished. What should I do?

From an axiomatic set theoric approach why can we take uncountable unions?

Are small insurances worth it?

Power Strip for Europe

When Schnorr signatures are part of Bitcoin will it be possible validate each block with only one signature validation?

Virginia employer terminated employee and wants signing bonus returned

Why does cron require MTA for logging?

Why is a very small peak with larger m/z not considered to be the molecular ion?

What is this diamond of every day?

Would an aboleth's Phantasmal Force lair action be affected by Counterspell, Dispel Magic, and/or Slow?

Does "Until when" sound natural for native speakers?

Was it really inappropriate to write a pull request for the company I interviewed with?

What is the generally accepted pronunciation of “topoi”?

What are some noteworthy "mic-drop" moments in math?

Why couldn't the separatists legally leave the Republic?

Does an unused member variable take up memory?

Are there historical instances of the capital of a colonising country being temporarily or permanently shifted to one of its colonies?

What ability score modifier does a javelin's damage use?

Do cubics always have one real root?



Combining Express 4 and Vue CLI 3



2019 Community Moderator ElectionHow do I install package.json dependencies in the current directory using npmCannot run index.js in nodejs with expressWhy use peer dependencies in npm for plugins?Error while installing vue-clivue-cli v3 with node.js firebase functions, firebase hosting (Error: No npm package found in functions source directory)problems with vue-cli for productionVue-cli-3 with EQCSSComponent(.vue file) editable build with vue cli 3Why when i create a vue project with 'vue-cli' fail?Vue CLI Child compilation failed after first build unless I clear .cache folder










0















I built a project with Vue CLI 3 and Express 4 and this went straight forward so far, as I had the backend server in one folder and the frontend in another, but now I'm coming to a halt trying to deploy both on a single Node hosting service. Let me tell more in a bit.



My project structure so far:



Project:
- node_modules/
- package.json

Project/Frontend (Vue CLI 3):
- node_modules/
- package.json
- app.js
- dist/
- <other folders like "public","tests","src",etc>

Project/Backend (Express 4):
- node_modules/
- package.json
- app.js
- <other folders like "controllers" and stuff>


Now, the problem is that I need to combine both in one Node app, in order to deploy it on a hosting serice.



I'd like to let Express (Backend) run the server and serve dist/ from the Frontend, but the problem is that the hosting service that I've chosen just runs npm install on the root folder, which isn't helpful, as I need the "Express" (and some others) package to run the server. Since it's not in the root folder, it doesn't install any packages and obviously fails to run.



I've created a root-level npm config to try to compile the Frontend and then copy dist/ to the Express backend. But since the hosting service doesn't install anything other than the root npm config, cd'ing into the Frontend and then building fails, as it misses node_modules.



I somehow managed to make this work by installing webpack on the backend folder's npm, configuring it to bundle the Express app and copying the bundle and the dist/ from the frontend in the root Project's folder and then running on the root-level npm:



cd frontend && npm run build && cd ../backend && webpack


and after that pushing the root dist/ to the hosting service, which kinda worked, but it's "fiddly" and not optimal, even more because I need to build it everytime on the local computer and only then upload it. If I somehow could utilize the root npm's packages to build frontend and backend on the hosting service, it would be great, but I believe here versioning is another issue, since both would share the same npm packages.



Is there any better and/or cleaner solution to this?



If any detail is missing, just let me know.



Thanks for any help in advance.










share|improve this question




























    0















    I built a project with Vue CLI 3 and Express 4 and this went straight forward so far, as I had the backend server in one folder and the frontend in another, but now I'm coming to a halt trying to deploy both on a single Node hosting service. Let me tell more in a bit.



    My project structure so far:



    Project:
    - node_modules/
    - package.json

    Project/Frontend (Vue CLI 3):
    - node_modules/
    - package.json
    - app.js
    - dist/
    - <other folders like "public","tests","src",etc>

    Project/Backend (Express 4):
    - node_modules/
    - package.json
    - app.js
    - <other folders like "controllers" and stuff>


    Now, the problem is that I need to combine both in one Node app, in order to deploy it on a hosting serice.



    I'd like to let Express (Backend) run the server and serve dist/ from the Frontend, but the problem is that the hosting service that I've chosen just runs npm install on the root folder, which isn't helpful, as I need the "Express" (and some others) package to run the server. Since it's not in the root folder, it doesn't install any packages and obviously fails to run.



    I've created a root-level npm config to try to compile the Frontend and then copy dist/ to the Express backend. But since the hosting service doesn't install anything other than the root npm config, cd'ing into the Frontend and then building fails, as it misses node_modules.



    I somehow managed to make this work by installing webpack on the backend folder's npm, configuring it to bundle the Express app and copying the bundle and the dist/ from the frontend in the root Project's folder and then running on the root-level npm:



    cd frontend && npm run build && cd ../backend && webpack


    and after that pushing the root dist/ to the hosting service, which kinda worked, but it's "fiddly" and not optimal, even more because I need to build it everytime on the local computer and only then upload it. If I somehow could utilize the root npm's packages to build frontend and backend on the hosting service, it would be great, but I believe here versioning is another issue, since both would share the same npm packages.



    Is there any better and/or cleaner solution to this?



    If any detail is missing, just let me know.



    Thanks for any help in advance.










    share|improve this question


























      0












      0








      0








      I built a project with Vue CLI 3 and Express 4 and this went straight forward so far, as I had the backend server in one folder and the frontend in another, but now I'm coming to a halt trying to deploy both on a single Node hosting service. Let me tell more in a bit.



      My project structure so far:



      Project:
      - node_modules/
      - package.json

      Project/Frontend (Vue CLI 3):
      - node_modules/
      - package.json
      - app.js
      - dist/
      - <other folders like "public","tests","src",etc>

      Project/Backend (Express 4):
      - node_modules/
      - package.json
      - app.js
      - <other folders like "controllers" and stuff>


      Now, the problem is that I need to combine both in one Node app, in order to deploy it on a hosting serice.



      I'd like to let Express (Backend) run the server and serve dist/ from the Frontend, but the problem is that the hosting service that I've chosen just runs npm install on the root folder, which isn't helpful, as I need the "Express" (and some others) package to run the server. Since it's not in the root folder, it doesn't install any packages and obviously fails to run.



      I've created a root-level npm config to try to compile the Frontend and then copy dist/ to the Express backend. But since the hosting service doesn't install anything other than the root npm config, cd'ing into the Frontend and then building fails, as it misses node_modules.



      I somehow managed to make this work by installing webpack on the backend folder's npm, configuring it to bundle the Express app and copying the bundle and the dist/ from the frontend in the root Project's folder and then running on the root-level npm:



      cd frontend && npm run build && cd ../backend && webpack


      and after that pushing the root dist/ to the hosting service, which kinda worked, but it's "fiddly" and not optimal, even more because I need to build it everytime on the local computer and only then upload it. If I somehow could utilize the root npm's packages to build frontend and backend on the hosting service, it would be great, but I believe here versioning is another issue, since both would share the same npm packages.



      Is there any better and/or cleaner solution to this?



      If any detail is missing, just let me know.



      Thanks for any help in advance.










      share|improve this question
















      I built a project with Vue CLI 3 and Express 4 and this went straight forward so far, as I had the backend server in one folder and the frontend in another, but now I'm coming to a halt trying to deploy both on a single Node hosting service. Let me tell more in a bit.



      My project structure so far:



      Project:
      - node_modules/
      - package.json

      Project/Frontend (Vue CLI 3):
      - node_modules/
      - package.json
      - app.js
      - dist/
      - <other folders like "public","tests","src",etc>

      Project/Backend (Express 4):
      - node_modules/
      - package.json
      - app.js
      - <other folders like "controllers" and stuff>


      Now, the problem is that I need to combine both in one Node app, in order to deploy it on a hosting serice.



      I'd like to let Express (Backend) run the server and serve dist/ from the Frontend, but the problem is that the hosting service that I've chosen just runs npm install on the root folder, which isn't helpful, as I need the "Express" (and some others) package to run the server. Since it's not in the root folder, it doesn't install any packages and obviously fails to run.



      I've created a root-level npm config to try to compile the Frontend and then copy dist/ to the Express backend. But since the hosting service doesn't install anything other than the root npm config, cd'ing into the Frontend and then building fails, as it misses node_modules.



      I somehow managed to make this work by installing webpack on the backend folder's npm, configuring it to bundle the Express app and copying the bundle and the dist/ from the frontend in the root Project's folder and then running on the root-level npm:



      cd frontend && npm run build && cd ../backend && webpack


      and after that pushing the root dist/ to the hosting service, which kinda worked, but it's "fiddly" and not optimal, even more because I need to build it everytime on the local computer and only then upload it. If I somehow could utilize the root npm's packages to build frontend and backend on the hosting service, it would be great, but I believe here versioning is another issue, since both would share the same npm packages.



      Is there any better and/or cleaner solution to this?



      If any detail is missing, just let me know.



      Thanks for any help in advance.







      node.js express npm vue-cli-3






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 6 at 14:32







      Fusseldieb

















      asked Mar 6 at 14:27









      FusseldiebFusseldieb

      643723




      643723






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55025417%2fcombining-express-4-and-vue-cli-3%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55025417%2fcombining-express-4-and-vue-cli-3%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко