How to “upload” my nodejs source code to production server?












1















I am not asking about deploying Node.js app or how do I deal with node_modules package, I am talking about "upload" my own nodejs code to production server.



So far I have tried 3 ways, each with its own pros & cons



git clone. To reduce to the cloned stuff I use git clone --depth 1 -b release_branch. But still I got the files I do not need for deployment, e.g except for .git I also get documents (b/c I put documents in my git repo).



npm install. use npm install git+https://gitusername:gitpassword@myserver/path/to/repo.git. With proper package.json files setting I can get my source codes only, which is what I want. But the problem is the directory structure. After running npm install, the directory is like this,



.
├── node_modules
└── package-lock.json

My package is located inside node_modules alongside with its own dependencies.


npm pack. Then upload (scp in my case) the tgz file to server, then npm install tgz_file.tgz --production But it has the same problem with npm install git+https. It is probably better than npm install git+https b/c I can control my releases.



So is there other ways (simple) that I can get proper directory structure and source codes only ?



BTW, I know this nodejs express app deploying to production but their discussion is not the same as mine.



----- update -----



Now I am kinda sure npm install tarball has some bug, so I just tar xf & npm i I believe this is the simplest solution.










share|improve this question

























  • what is the difference between uploading code for deployment and your scenario?

    – Zain
    Nov 22 '18 at 6:53













  • no difference. first upload my code then npm install then npm start

    – Qiulang
    Nov 22 '18 at 6:54











  • have you tried scp ?

    – Zain
    Nov 22 '18 at 6:58











  • I don't exactly understand what is your problem, but I think with scp (and may a small shell script) you will have control over the trasfered files.

    – Zain
    Nov 22 '18 at 6:59
















1















I am not asking about deploying Node.js app or how do I deal with node_modules package, I am talking about "upload" my own nodejs code to production server.



So far I have tried 3 ways, each with its own pros & cons



git clone. To reduce to the cloned stuff I use git clone --depth 1 -b release_branch. But still I got the files I do not need for deployment, e.g except for .git I also get documents (b/c I put documents in my git repo).



npm install. use npm install git+https://gitusername:gitpassword@myserver/path/to/repo.git. With proper package.json files setting I can get my source codes only, which is what I want. But the problem is the directory structure. After running npm install, the directory is like this,



.
├── node_modules
└── package-lock.json

My package is located inside node_modules alongside with its own dependencies.


npm pack. Then upload (scp in my case) the tgz file to server, then npm install tgz_file.tgz --production But it has the same problem with npm install git+https. It is probably better than npm install git+https b/c I can control my releases.



So is there other ways (simple) that I can get proper directory structure and source codes only ?



BTW, I know this nodejs express app deploying to production but their discussion is not the same as mine.



----- update -----



Now I am kinda sure npm install tarball has some bug, so I just tar xf & npm i I believe this is the simplest solution.










share|improve this question

























  • what is the difference between uploading code for deployment and your scenario?

    – Zain
    Nov 22 '18 at 6:53













  • no difference. first upload my code then npm install then npm start

    – Qiulang
    Nov 22 '18 at 6:54











  • have you tried scp ?

    – Zain
    Nov 22 '18 at 6:58











  • I don't exactly understand what is your problem, but I think with scp (and may a small shell script) you will have control over the trasfered files.

    – Zain
    Nov 22 '18 at 6:59














1












1








1


1






I am not asking about deploying Node.js app or how do I deal with node_modules package, I am talking about "upload" my own nodejs code to production server.



So far I have tried 3 ways, each with its own pros & cons



git clone. To reduce to the cloned stuff I use git clone --depth 1 -b release_branch. But still I got the files I do not need for deployment, e.g except for .git I also get documents (b/c I put documents in my git repo).



npm install. use npm install git+https://gitusername:gitpassword@myserver/path/to/repo.git. With proper package.json files setting I can get my source codes only, which is what I want. But the problem is the directory structure. After running npm install, the directory is like this,



.
├── node_modules
└── package-lock.json

My package is located inside node_modules alongside with its own dependencies.


npm pack. Then upload (scp in my case) the tgz file to server, then npm install tgz_file.tgz --production But it has the same problem with npm install git+https. It is probably better than npm install git+https b/c I can control my releases.



So is there other ways (simple) that I can get proper directory structure and source codes only ?



BTW, I know this nodejs express app deploying to production but their discussion is not the same as mine.



----- update -----



Now I am kinda sure npm install tarball has some bug, so I just tar xf & npm i I believe this is the simplest solution.










share|improve this question
















I am not asking about deploying Node.js app or how do I deal with node_modules package, I am talking about "upload" my own nodejs code to production server.



So far I have tried 3 ways, each with its own pros & cons



git clone. To reduce to the cloned stuff I use git clone --depth 1 -b release_branch. But still I got the files I do not need for deployment, e.g except for .git I also get documents (b/c I put documents in my git repo).



npm install. use npm install git+https://gitusername:gitpassword@myserver/path/to/repo.git. With proper package.json files setting I can get my source codes only, which is what I want. But the problem is the directory structure. After running npm install, the directory is like this,



.
├── node_modules
└── package-lock.json

My package is located inside node_modules alongside with its own dependencies.


npm pack. Then upload (scp in my case) the tgz file to server, then npm install tgz_file.tgz --production But it has the same problem with npm install git+https. It is probably better than npm install git+https b/c I can control my releases.



So is there other ways (simple) that I can get proper directory structure and source codes only ?



BTW, I know this nodejs express app deploying to production but their discussion is not the same as mine.



----- update -----



Now I am kinda sure npm install tarball has some bug, so I just tar xf & npm i I believe this is the simplest solution.







node.js git npm deployment production-environment






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 15:59







Qiulang

















asked Nov 22 '18 at 4:54









QiulangQiulang

2,19322850




2,19322850













  • what is the difference between uploading code for deployment and your scenario?

    – Zain
    Nov 22 '18 at 6:53













  • no difference. first upload my code then npm install then npm start

    – Qiulang
    Nov 22 '18 at 6:54











  • have you tried scp ?

    – Zain
    Nov 22 '18 at 6:58











  • I don't exactly understand what is your problem, but I think with scp (and may a small shell script) you will have control over the trasfered files.

    – Zain
    Nov 22 '18 at 6:59



















  • what is the difference between uploading code for deployment and your scenario?

    – Zain
    Nov 22 '18 at 6:53













  • no difference. first upload my code then npm install then npm start

    – Qiulang
    Nov 22 '18 at 6:54











  • have you tried scp ?

    – Zain
    Nov 22 '18 at 6:58











  • I don't exactly understand what is your problem, but I think with scp (and may a small shell script) you will have control over the trasfered files.

    – Zain
    Nov 22 '18 at 6:59

















what is the difference between uploading code for deployment and your scenario?

– Zain
Nov 22 '18 at 6:53







what is the difference between uploading code for deployment and your scenario?

– Zain
Nov 22 '18 at 6:53















no difference. first upload my code then npm install then npm start

– Qiulang
Nov 22 '18 at 6:54





no difference. first upload my code then npm install then npm start

– Qiulang
Nov 22 '18 at 6:54













have you tried scp ?

– Zain
Nov 22 '18 at 6:58





have you tried scp ?

– Zain
Nov 22 '18 at 6:58













I don't exactly understand what is your problem, but I think with scp (and may a small shell script) you will have control over the trasfered files.

– Zain
Nov 22 '18 at 6:59





I don't exactly understand what is your problem, but I think with scp (and may a small shell script) you will have control over the trasfered files.

– Zain
Nov 22 '18 at 6:59












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%2f53424108%2fhow-to-upload-my-nodejs-source-code-to-production-server%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%2f53424108%2fhow-to-upload-my-nodejs-source-code-to-production-server%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

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?