简体   繁体   English

NPM生产开发上直播服务器

[英]NPM production and development on live server

This might be a silly question but I am using npm first time in my project so I need to know best practice for this.这可能是一个愚蠢的问题,但我第一次在我的项目中使用npm所以我需要知道这方面的最佳实践。

How do I manage npm development and npm production on local and production server?如何在本地和生产服务器上管理npm developmentnpm production

As of now I run npm run development command when developing and save the compiled files along with other changes on git .截至目前,我在开发时运行npm run development命令并保存编译文件以及git上的其他更改。

Before I pull all the changes on production server, I run npm run production command and commit on git .在我拉出生产服务器上的所有更改之前,我运行npm run production命令并在git上提交。 After that I pull the latest changes on production and then run npm run development on my local branch.之后,我在生产中提取最新更改,然后在我的本地分支上运行npm run development

What are the best practice to do this?执行此操作的最佳做法是什么?

Thank you谢谢

The 'Best Practice' is that you don't commit any compiled files . “最佳实践”是您不提交任何已编译的文件

You should use .gitignore to ignore the folder that your files are compiled into.您应该使用.gitignore忽略文件编译到的文件夹。 But before you do that, delete the folder and commit the deletion, so that Git understands those files are gone.在你这样做之前,删除文件夹并提交删除,以便 Git 了解这些文件已经消失。 Then add the folder to .gitignore and you can carry on.然后将文件夹添加到.gitignore即可继续。

On your local machine, you can run npm run development .在您的本地机器上,您可以运行npm run development Then on your production server, or on a build machine, you can run npm run production .然后在您的生产服务器或构建机器上,您可以运行npm run production

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM