AWS Elastic Beanstalk:我是否必须使用完整的“/ node_modules”和“/ bower_components”以及编译的sass和其他依赖项来部署我的应用程序?

时间:2022-07-24 07:27:57

I don't understand the way AWS Elastic Beanstalk work in terms of Node.js app. Best practices of Node.js development say that one don't have to push /node_modules or /bower_components or other third party packages to version control systems (GitHub, for example), only package.json. All those /node_modules have to be in .gitignore. Then any person can do npm install or bower install and install all the dependencies. And the same is for sass - compile them for production env.

我不了解AWS Elastic Beanstalk在Node.js应用程序方面的工作方式。 Node.js开发的最佳实践表明,不必将/ node_modules或/ bower_components或其他第三方软件包推送到版本控制系统(例如GitHub),只需将package.json推送到版本控制系统。所有这些/ node_modules都必须在.gitignore中。然后任何人都可以执行npm install或bower安装并安装所有依赖项。同样适用于sass - 将它们编译为生产环境。

Ok, but what about AWS Elastic Beanstalk? How do I have to create a source bundle of my Node.js app? Do I have to commit FULL /node_modules and /bower_components and then make a .zip bundle with them? But my HEAD commit is without /node_modules, because /node_modules is in .gitignore. So no dependencies will be in .zip bundle:

好的,但是AWS Elastic Beanstalk呢?我如何创建Node.js应用程序的源包?我是否必须提交FULL / node_modules和/ bower_components,然后使用它们生成.zip包?但我的HEAD提交没有/ node_modules,因为/ node_modules在.gitignore中。所以.zip包中没有依赖项:

git archive --format=zip HEAD > app.zip

Or do I have an option to install all the dependencies AFTER I have deployed my app.zip to AWS Elastic Beanstalk?

或者,在将app.zip部署到AWS Elastic Beanstalk之后,我是否可以选择安装所有依赖项?

Or AWS Elastic Beanstalk does npm install by itself somewhere under the hood immediately after I have uploaded my app.zip bundle?

或者,当我上传app.zip包后,AWS Elastic Beanstalk会立即在某个地方安装npm吗?

1 个解决方案

#1


2  

Elastic Beanstalk runs a few npm commands when deploying your app using got. I did a little experiment a few months back.

使用got部署应用程序时,Elastic Beanstalk会运行几个npm命令。几个月前我做了一个小实验。

In short, you can use npm install to deploy your dependencies, then use npm prestart to build and compile things like sass.

简而言之,您可以使用npm install来部署依赖项,然后使用npm prestart来构建和编译sass之类的东西。

#1


2  

Elastic Beanstalk runs a few npm commands when deploying your app using got. I did a little experiment a few months back.

使用got部署应用程序时,Elastic Beanstalk会运行几个npm命令。几个月前我做了一个小实验。

In short, you can use npm install to deploy your dependencies, then use npm prestart to build and compile things like sass.

简而言之,您可以使用npm install来部署依赖项,然后使用npm prestart来构建和编译sass之类的东西。