简体   繁体   中英

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?

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.

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM