80

I would like to use angular.js for my Image Editing Tool in my website. Do I need node.js also?

I don't understand the scenario. If I don't need it, then when do we use both nodejs and angularjs together?

5
  • Different things. (only common thing is JavaScript)CommentedOct 16, 2014 at 7:28
  • One is client and one is server. JavaScript in the client is not dependent on that same language on the server. What is the confusion here?
    – Neil Lunn
    CommentedOct 16, 2014 at 7:29
  • 1
    In simple terms answer is noCommentedOct 16, 2014 at 7:32
  • 1
    after came to know what is angular and node js this question seems silly to me.. :-PCommentedAug 4, 2016 at 11:31
  • 7
    I think the tutorial on Angular's official website makes everyone confused. It uses NodeJS as a backend server. In fact, unless you are using AJAX or anything like that, you can run Angular solely on your computer with no problems.
    – Aaron Liu
    CommentedAug 9, 2016 at 19:39

7 Answers 7

83

I feel your pain.

For someone new to Angular 2 development, I can feel the pain of having to learn server side technologies for something that is essentially a client side technology. From what I understand:

  1. node.js is only used to manage the dependencies of an angular 2 application. If you can somehow manage to get those dependencies without using node.js, npm or jspm then you can run and develop your application offline. However, doing it manually will take an inexorable amount of time since you have to download files manually which may have other dependencies which will require other files to be downloaded again (yes I've been there). node.js or npm or jspm for that matter automates this process as well as taking all the necessary steps of configuring the files (jspm) so that whenever you use a particular dependency in your application, that particular dependency's other dependency will also be present in your system.
  2. Some browsers, particularly Google Chrome restricts files loaded locally for security purposes so that certain HTML 5 technologies used by Angular 2 will produce an error when loaded using the file: protocol. So you need a server from which you can serve your application so that all the available HTML 5 technologies is available for Angular 2 to run.
  3. node.js is also needed for the hot-module-reload capability for rapid application development since it provides a file watcher api to detect changes to source code.

But there is a way to develop Angular 2 application offline without node.js.

  1. Remember when I said that if you can manage to get all the required dependencies, you can run and develop your application offline? If you can somehow find or create a package that has all the required dependencies your application will need, then you do not need npm or jspm to manage the dependencies for you.
  2. For the file-access-restriction problem, you can load your project as an extension. Extensions have the ability to use all the available HTML 5 technologies as well as some powerful api's (not available even to applications served on a server), while at the same time being local to your development environment. So you do not need to fire a web server to access HTML 5 technologies if you serve your application as an extension.
  3. For the hot-module-reload capability, you can approach it from the other way. Instead of having a file watcher in the web server to monitor changes to files in the local system, you can do it from the application itself. Since the application can fetch or xmlhttprequest resources that are needed by the application, you can periodically fetch or xmlhttprequest the resources your application needs and compare it to some cache. But how do you know which files to check? You can look for links within the page, script, of img. If you use SystemJS as the module loader, then you can use its registry to look for the files needed by your application but not loaded in the page, since it has been transpiled or something. While doing all this can be a performance drain to your system along with the added overhead of transpiling or preprocessing non-native code, this job can be outsourced to a web worker which will free up the main execution thread in the system for your application code.

Don't believe me? Here's proof.

  1. The Angular in Chrome project on github contains a zipped package which contains the required dependencies needed to develop a minimal Angular 2 application (by minimal, I am referring to the Tour of Heroes tutorial referred on the quickstart page). So that if you are on a system not supported by node.js (yes there are, ChromeOS for instance) or just on a restricted system in which node.js just isn't available, all the required dependencies are available and you do not need npm or jspm to manage the required dependencies for you.
  2. There is a proof of concept extension which serves the tour of heroes tutorial (the development files, typescript and all) locally as a chrome extension.
  3. The extension also implements a hot-module-reload functionality by hooking into the hmr-primitives developed by alexis vincent for SystemJS. The hot-module-reload functionality is enabled by a single javascript file so that if this functionality is not needed or is taking up too much resources, then you can just remove the offending line of code.

But be warned though.

  1. If you are using this system, then you need a way to update your development package as technology moves forward and it moves at a rapid pace (what with talk of Angular 3 when Angular 2 has just been released) or the technologies that you are using to develop your application may become obsolete or that somewhere along the line an api change may prevent your application from being functional in the future. You are also not guaranteed to have up-to-date repositories for the dependencies since these types of packages are maintained manually.
  2. Bundling your application as a Chrome extension like in Angular in Chrome will introduce performance bottlenecks. Since code is transpiled and modules are lazy loaded, you lose the advances of JIT compilation and other performance enhancements that modern javascript engines use to optimize code run on the browser. However, what you lose in performance, you gain the flexibility to use the technology that you prefer to develop in. There is always a tradeoff. Moreover, the performance hit is only at the beginning as code is loaded. Once it has been loaded by the application, then the system will know how to implement the performance enhancements. When you distribute your application, you really need to compile the needed resources to take advantage of the performance enhancements of modern javascript engines.
  3. The hot-module-reload capability is currently a hackish way of implementing a file watcher which uses common conventions for a project (temp1.ts, temp1.css, temp1.htm) since there is no way (I might be wrong on this) to get a definitive list of all the resources needed by the application but not loaded on the main page (the transpiled or pre-processed resources).
1
  • I'm not agree, nodejs is not the only server side technologie. I think the question is much more about using grunt, yeoman etc that need to install nodejs.CommentedSep 26, 2017 at 5:33
67

You don't need NodeJS for creating a client side image editing tool.

AngularJS is a web application framework, maintained by Google and the community, that assists with creating single-page applications, which consist of one HTML page with CSS and JavaScript on the client side.

But if someday you will want to upload and store those images on a server and make them accessible by multiple clients - then yes you will also need a server. This server could be made with NodeJS.

5
  • 1
    Thank you @Catalin Munteanu . Now i understand what it means.CommentedOct 16, 2014 at 7:44
  • 2
    Also when you get to need a server I recommend you create one from scratch. You need to understand how it works before using a complex framework like MEAN or SailsJS.CommentedOct 16, 2014 at 7:49
  • 1
    ,i am handling image on server by phpCommentedOct 16, 2014 at 7:50
  • What if I have a backend application up and running and all I want to build is just the front end? Does angular only is good enough?
    – Arun
    CommentedJan 28, 2019 at 21:10
  • @Arun, you don't need NodeJS if you want to build the frontend with AngularJS.CommentedFeb 3, 2019 at 15:31
9

node.js is used to write Javascript on the server side. angular.js is a client side framework.

You don't need node.js to use angular.js but, you can install npm (node package manager) to use some awesome tools that will make your life as an angular developer much easier. For example: yoeman which is a great scaffolding tool. There are many other tools available on npm here is a link to their site Learn more about angular at the official angular website or at the angular youtube channel

3
  • 2
    This answer is what I find confusing about Angular and NodeJS: On the CLIENT, there are so many tools that require NodeJS--basically anything that is installed using the node package manager (npm) utility. What I still do not understand is when it comes times to HOST the site that used NodeJS and npm-installed packages on the client--do you also need to have NodeJS on the server for those installed packages to work? If the answer is "maybe" then what factors are involved in knowing whether NodeJS needs to be on the web server as well?
    – Jazimov
    CommentedJan 12, 2016 at 18:10
  • 1
    To answer your question, yes and no. npm is a package manager. Installing a package with npm is the same as copying the package and its dependencies to your local directory. So if you want the nice features that come with npm then you should install npm and you need node to do that. If you don't need the features of npm then you don't have to install it and you can copy packages down yourself. Lets say your site needs to use this date picker if you run an install comment that will copy it and angularjs down or you can do that manually.
    – hasanain
    CommentedJan 14, 2016 at 23:25
  • Thanks--I may post a new question to follow up further. But I understood your example. I'm a .NET programmer and would host on a Windows server that runs IIS. Most hosting companies don't seem to support NodeJS on the server; then again, most of what I'm doing on the client with Node is using its npm (package manager) util to "install" add-ons/dependencies. After that, I do expect that I could just copy the configured files to the web server and they would run fine without node. I don't see why I would want node on the server unless I had console access anyway and could run npm on it as needed
    – Jazimov
    CommentedJan 15, 2016 at 2:55
8

No. Angular is used at the client side and Node for the server side.

They use to go together as the MEAN Stack but it's not necessary.

    3

    You don't need Node.JS for AngularJS to work. NodeJS is server side, AngularJS is client side.

    If you are new to AngularJS, I'd suggest this tutorial AngularJS tutorial. In the tutorial you will use NodeJS, you will understand why the two work together, but are not necessary.

      3

      It's hard to answer without knowing how your Imaging editing tool works. But to answer your question, no you do not need Node.js to use AngularJS.

      Angular is a front-end javascript framework which operates in the clients web browser.

      Node is a service which can execute javascript and is often used on a server maybe in replacement of PHP (like in MEAN stack). Also, because Node is a service which can execute javascript it can be used in your local computer when developing Angular applications to do background tasks such as minifying css and javascript and performing tests.

      So if your Imaging editing tool is developed in javascript and your application used Angular and Node (as a web server), the code could be executed on either client side or server side.

      Have a read on MEAN stack to see where Node and Angular fit in. You don't even need Node at all but it's nice to develop all in the same language.

      2
      • Now I just decided that i can use angularjs to handle,a user can upload image and use options such as (rotate, crop).I need to manage these images That's all in my imageediting tool functions.CommentedOct 16, 2014 at 7:49
      • 1
        For user image manipulation like rotate and crop it makes sense to have that functionality on the frontend.For routine functionality like image resizing you could put that on a node server to free up client resources. These days client side hardware is pretty powerful there is probably no need.
        – JayMc
        CommentedOct 16, 2014 at 7:54
      0

      Reason for installing NodeJs As a web browser such as Chrome, Firefox etc. understands only JavaScript, we have to transpile our Typescript to JavaScript. Therefore, the Typescript transpiler requires Node.js for generating the Typescript code to JavaScript.

        Start asking to get answers

        Find the answer to your question by asking.

        Ask question

        Explore related questions

        See similar questions with these tags.