1

What I want to do is very basic. I want to install AngularJS v1.5.x using npm and then have it available for me to utilize within my application. All the tutorials I see out there are just downloading the Angular Version from angularjs.org then including it in their index.html in a <script></script> tag. But I want to use npm to install AngularJS and then make it available for me to use within my index.html like a real developer might do!

Here are the commands I've run.

$ npm init
$ npm install [email protected] --save
[email protected] /Users/theDanOtto/Sites/Playground/npm-angular-test
└── [email protected]

Here is my basic package.json

{
  "name": "npm-angular-test",
  "version": "1.0.0",
  "description": "", 
  "main": "index.js",
  "dependencies": {
    "angular": "^1.5.7"
  },  
  "devDependencies": {}, 
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },  
  "author": "", 
  "license": "ISC"
}

I created an index.js, but I left it blank. I then added a src tag in my index.html to include index.js.

<!DOCTYPE html>
<html ng-app>
<head>
  <title>Html</title>
  <script src="index.js"></script>
</head>
<body>
  <p>My first expression: {{ 5 + 5  }}</p>
</body>
</html>

My expression simply writes {{ 5 + 5 }} instead of 10. Where am I headed wrong?

1 Answer 1

4

Either include Angular.js via

<script type="text/javascript" src="node_modules/somefile.js"></script>

though i use bower, check were angularJS file is located after installing it via npm

or use requireJS

npm is only some manager for frontend libraries in your repository, not for including it into the webapp

Sign up to request clarification or add additional context in comments.

1 Comment

In this case "/node_modules/somefile.js" should be "/node_modules/angular/angular.js" (or "/bower_components/angular/angular.js" when using bower) according to npmjs.com/package/angular

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.