简体   繁体   中英

how to add angular js to an existing node.js application?

I am working my way through building my first node.js app, with a mongodb backend. I didn't install any frameworks (like mean.io) but am just trying to build step by step so I understand what each component does etc.

So far, so good. My node js app exposes a GET method via express, and queries my mongdb. Right now it just dumps out a bunch of json data.

Now, I'd like to start working on the GUI. So I've been looking at angularjs. I've installed it using this command:

me@mydevbox:/var/www/html/node/inventory$ sudo npm install angularjs
inventory@0.0.0 /var/www/html/node/inventory
└── angularjs@0.0.1 

When i check npm for an inventory of what's been installed, this is what I see: (this is just a partial list... to keep my question / post short and readable)

me@mydevbox:/var/www/html/node/inventory$ npm ls
inventory@0.0.0 /var/www/html/node/inventory
├── angularjs@0.0.1 extraneous
├─┬ mongodb@2.2.5
│ ├── es6-promise@3.0.2
│ ├─┬ mongodb-core@2.0.7
│ │ ├── bson@0.5.2
│ │ └─┬ require_optional@1.0.0
│ │   ├── resolve-from@2.0.0
│ │   └── semver@5.3.0
│ └─┬ readable-stream@1.0.31
│   ├── core-util-is@1.0.2
│   ├── isarray@0.0.1
│   └── string_decoder@0.10.31
├─┬ mongoose@4.5.8
│ ├── async@1.5.2
│ ├── bson@0.4.23
│ ├── hooks-fixed@1.2.0
│ ├── kareem@1.1.3
│ ├─┬ mongodb@2.1.18
│ │ └── mongodb-core@1.3.18
│ ├── mpath@0.2.1
│ ├── mpromise@0.5.5
│ ├─┬ mquery@1.11.0
│ │ ├── bluebird@2.10.2
│ │ ├── debug@2.2.0
│ │ └── sliced@0.0.5
│ ├── muri@1.1.0
│ ├── regexp-clone@0.0.1
│ └── sliced@1.0.1
├─┬ morgan@1.6.1
│ ├── basic-auth@1.0.4
│ └── on-headers@1.0.1
└── serve-favicon@2.3.0

npm ERR! extraneous: angularjs@0.0.1 /var/www/html/node/inventory/node_modules/angularjs

In reading other posts, some seemed to suggest it has to do with the user (eg. not using root) you install the package with. But that doesn't seem to be the problem here.

Questions

I'd like some help diagnosing this error that I'm seeing... Also once I have it installed properly, what's the best way to integrate angular into my existing node js application? The examples I've seen online talk about how to initialize a new app but that's not what I'm looking for.

Thanks!

npm ERR! extraneous means you didn't save the module in your package.json

Install again using --save

npm install angular --save

(Also you installed angularjs instead of angular, I don't know the difference, but I would check it out)

The integration between the backend and the front in angular is made with services and the $http angular object.

I recommend you to do some angular tutorials, google has lots of them.

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