Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to include a private local file in javascript project using bower

i want to include a custom file as one of the bower dependency.

I am have the following bower.json

{
  "name": "xyz",
  "version": "0.0.0",
  "dependencies": {
    "sass-bootstrap": "~2.3.0",
    "requirejs": "~2.1.4",
    "modernizr": "~2.6.2",
    "jquery": "~1.9.1",
    "beautify": "file:/path/to/beautify.js"
  },

  "devDependencies": {}
}

But when i do bower install it gives error :

 bower beautify#*             ENOTFOUND Package file:/path/to/beautify.js not found

however when i open the same path in browser i get the right file. I have also checked the case sensitive of the path.

Now can any one tell me what error i am doing? Is there any thing wrong with the syntax?

Also tell me what if i want to add the same via bower cache. Where the global bower cache is stored in mac? And how can we register the url of private package so that i just need to put name of the package in bower.json and bower finds the file from the cache?

like image 413
codeofnode Avatar asked Aug 19 '13 15:08

codeofnode


People also ask

What is bower in JavaScript?

Bower is a package manager for client-side libraries and components that contain HTML, CSS, JavaScript, fonts, image files, and so on. You can install, locate, upgrade, and remove Bower packages without leaving WebStorm, on the dedicated Bower page or from the command line in the built-in terminal.

What is the use of bower JSON file?

json file which defines some information about the projects as well as a list of dependencies. The bower. json file is actually used to define a Bower package, so in effect you're creating your own package that contains all of the dependencies for your application.

What are bower packages?

Bower is a package manager, like npm, which manages frameworks, libraries, assets, and utilities, installs them, and makes sure they are up to date. Traditionally, many web development projects combined npm and Bower. npm was used to manage back-end dependencies, while Bower was used for front-end dependencies.


3 Answers

The code below didn't work for me using Bower 1.2.8 on Ubuntu.

"beautify": "/path/to/beautify.js"

What did work was using: "beautify": "./path/to/beautify.js". This way the path is pointing to the file relative from the directory where bower.json resides.

like image 56
Tijhaart Avatar answered Sep 21 '22 15:09

Tijhaart


It should be just /relative/path/to/beautify.js. No 'file:/'.

"beautify": "/path/to/beautify.js"
like image 43
Sheng Avatar answered Sep 21 '22 15:09

Sheng


If you have bower installed you can do this from the commandline

bower install ../beautify.js -S

Assuming the local repo is a directory next to your current directory. This is just a testing approach and should be an available repo for general use


EDIT

It looks like you also need to tag your repo so you will pick up the latest changes too

git tag v0.0.2
like image 21
KeepCalmAndCarryOn Avatar answered Sep 18 '22 15:09

KeepCalmAndCarryOn