Reputation: 18834
I've been working with angular and using bower as a package manager. For a current project I want to use some npm modules in the browser and started with browserify
For my starter project I was able to npm install angular angular-ui-router --save
because they have npm packages but I'm used to installing dependencies with bower install
Building my browserify-angular app, how do I install dependencies that aren't listed on npm? Essentially does browserify have a replacement to bower install
, or could I use bower with browserify?
For the current project I have a package.json
looking like so:
{
"name": "browserify-begin",
"version": "0.0.0",
"dependencies": {
"7digital-api": "^0.15.2",
"angular": "^1.2.16",
"angular-ui-router": "^0.2.10"
},
"devDependencies": {
"browserify": "^4.1.5",
"grunt": "^0.4.5",
"grunt-browserify": "^2.1.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-copy": "^0.5.0"
}
}
Upvotes: 4
Views: 1808
Reputation: 4274
You can try to install via debowerify
The package.json may then look as follows:
{
"name": "browserify-begin",
"version": "0.0.0",
"dependencies": {
"7digital-api": "^0.15.2",
"angular": "^1.2.16",
"angular-ui-router": "^0.2.10"
},
"browserify": {
"transform": [
"debowerify"
]
},
"devDependencies": {
"browserify": "^4.1.5",
"debowerify": "^0.7.1",
"grunt": "^0.4.5",
"grunt-browserify": "^2.1.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-copy": "^0.5.0"
}
}
Given the source javascript file is source.js And you want to browserified to build.js
Using debowerify, if your source.js contains bower components like bootstrap etc, for example:
require('bootstrap')
The Gruntfile.js will look like the following:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
browserify: {
bundleOptions: {
debug: true
},
js: {
src:['source.js'],
dest: 'build.js'
}
}
}),
grunt.loadNpmTasks('grunt-browserify');
}
build.js will include bootstrap component
Upvotes: 0
Reputation: 6489
You can install git-repos with npm without them being published to npm.
"dependencies": {
"package": "git+https://github.com/path/to/repo#commitSHAhash"
}
Upvotes: 2