Reputation: 7307
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?
Upvotes: 1
Views: 1281
Reputation: 663
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
Upvotes: 4