The accepted answer is not correct. In order to add client-side modules to your Ionic/AngularJS app, you should use Bower and not NPM. NPM should only be used to install modules that are part of the development/build/deployment processes. Anything you want to come across to your users as part of the client-side package should be managed by Bower.
If you look in the .bowerrc
file, you'll see the following:
{
"directory": "www/lib"
}
This configuration sets the www/lib
directory as the home for everything installed by bower. If you use the following command, the package will be installed in the correct location:
bower install --save angular-base64
(The --save
flag saves the dependency in your bower.json
file.)
You may now add the script tag to your index.html
file: <script src="lib/angular-base64/angular-base64.min.js"></script>
You will also need to inject the module into your app as described above. In app.js
add the module like so: angular.module('starter', ['base64'])
When using tools like Bower or NPM, I find that having to make manual modifications to an installation is often the first sign that I've done it wrong!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…