简体   繁体   中英

Typescript required for taking build in production with angular cli?

I have developed Angular 4 based application and providing the source file to build team and they have NodeJS and Angular CLI, could TypeScript required to build the source code in production with their machine?

for ng build--prod

This is rather unclear but I will try my best to answer (from what I have understood on my own).

When you create an Angular project with the CLI, it installs all the required dependencies, such as Typescript, or SASS, for instance.

When you build your application, you again type in the command ng build : this means you are actually using the CLI to build your application. The same CLI that has already installed all the required dependencies.

So, if you want to know if you need to install typescript as a global package, the answer is no. If you mean you need to install typescript as an application dependency, then the answer is yes.

In the end, all you need to do to deploy your app (or for your coworkers to deploy it), is the source code, and a global installation of the CLI.

I hope this helps !

Let me give you example of our usage of angular in production environment.

In our local machines, we have npm and angular-cli (global) installed, and once we are done with development, we merge our code into the repository and use jenkins build jobs to build our code. However, there may be other teams who use the same jenkins machine to build their own code and we may have different angular-cli version dependecies. Let's say our project uses angular-cli v1.5.4, and theirs use angular-cli v1.4. It would be a bad idea to install global angular-cli in the build machine. However, to run ng build --prod command, you need to have a globally installed angular-cli.

Instead of this, you should always build your code with npm run build command which will trigger the build script written in your package.json . This way, you don't need to have an globally installed angular-cli, npm will use local angular-cli within your project so that every team can build their code with different versions of angular-cli.

Hope this clarifies your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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