Reputation: 6297
I'm just beginning to read the angular2 quickstart and notice it is using npm, node and typescript. I was wondering what is the use of node.js in angular2? Isn't angular just a client side framework? So what is the use of node.js and what is node.js exactly doing? In the quickstart, it doesn't show you how to use angular2 without node.js. So I'm a bit confused since in my mind angular is just a client side framework.
Thanks for the clarification.
Upvotes: 3
Views: 1236
Reputation: 202138
The reason I think that Angular2 is provided as an NPM module is because of the TypeScript compilation.
The compiler requires d.ts
files for module contracts. Moreover when you specify the moduleResolution
attribute to node
in the tsconfig.json
file, it will load them through Node:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node", // <-----
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
That being said, Node isn't used within the Angular2 application itself when executing within the browser.
Upvotes: 0
Reputation: 2603
Fact: Sure, angularJS is a client side framework. But NODEJS is not a sever side framework, it is a platform which provides JavaScript Runtime Environment.
Why NodeJS is being used in Client Side Development:
npm install package_name --save
. So, no need to learn bower.NODEJS used in Angular2 (JavaScript) Documentation:
package.json
file which contains all the required libraries for the client app. npm install
and all the required libraries are downloaded in your local machine under node_modules
folder.<script src="node_modules/@angular/core/core.umd.js"></script>
lite-server
which serves your web app and live reloads it on changes. It is executed by npm start
check the script section in package.json.npm install jQuery --save
At the end of the day, NODEJS just makes your life easier with just one package.json file.
Upvotes: 3
Reputation: 184
Angular2 is a client side framework, it doesn't need nodejs in order to work. The confusion comes from typescript, because the typescript compiler runs on nodejs. Note that typescript supports ES6 which introduced the support for modules that have import and export functionality.
NodeJS became inseparable part of the front-end development cycle since it provides many tools for building apps, task runners, compilers, test frameworks etc. .
PS: There is an angular documentation dedicated for javascript: link
You can switch the languages from the dropdown menu under the main header. Sadly, at the moment most of the documentation is written only for Typescript. You can download already compiled source of angular2 and start using it without node.
Upvotes: 7