JavaScript package manager - using a browser-focused and RequireJS compatible repository

Related tags

Package Managers jam
Overview

****NOTE: this project is no longer active and not recommended for use. It is left here for reference. ****

Jam was created at a time before Bower and provided a (still to this day) very nice installation workflow which meant you could 'jam install jquery', then immediately 'require("jquery")' in your application. No manual bundling or build step (e.g. browserify, webpack) required. This was thanks in large part to the power and flexibility of the AMD format.

Since it's creation, NPM has set it's sights more firmly on the browser space, and the popularity of the AMD module format is waning. Jam never really got enough traction to compete. Thanks to everone that helped out and gave it a try.

If you want to try hosting your own Jam repository, see the repositories section below. The public Jam repository is now retired.


Jam

For front-end developers who crave maintainable assets, Jam is a package manager for JavaScript. Unlike other repositories, we put the browser first.

  • Manage dependencies - Using a stack of script tags isn't the most maintainable way of managing dependencies, with Jam packages and loaders like RequireJS you get automatic dependency resolution.

  • Fast and modular - Achieve faster load times with asynchronous loading and the ability to optimize downloads. JavaScript modules and packages provide properly namespaced and more modular code.

  • Use with existing stack - Jam manages only your front-end assets, the rest of your app can be written in your favourite language or framework. Node.js tools can use the repository directly with the Jam API.

  • Custom builds - No more configuring custom builds of popular libraries. Now, every build can be optimized automatically depending on the parts you use, and additional components can always be loaded later.

  • Focus on size - Installing multiple versions works great on the server, but client-side we don't want five versions of jQuery! Jam can use powerful dependency resolution to find a working set of packages using only a single version of each.

  • 100% browser - Every package you see here will work in the browser and play nicely with module loaders like RequireJS. We're not hijacking an existing repository, we're creating a 100% browser-focused community!

Visit the Jam website

Example usage

$ jam install jquery
<script src="jam/require.js"></script>

<script>
    require(['jquery'], function ($) {
        ...
    });
</script>

Learn more...

Browser packages in package.json

You can also define your browser dependencies in a project-level package.json file. If you use Node.js, this format will already familiar to you, and the Jam dependencies can live alongside your NPM dependencies. It's also possible to define custom install paths and baseUrls, as well as hand in any requirejs configuration here:

{
    "name": "my-project",
    "version": "0.0.1",
    "description": "My example project",
    "jam": {
        "baseUrl": "public",
        "packageDir": "public/vendor",
        "dependencies": {
            "jquery": "1.7.x",
            "underscore": null
        },
        "config": {
          "paths": {
            "templates": "public/templates"
          }
        }
    }
}

Installation

# npm install -g jamjs

Requires node.js

Settings

You can customize Jam by creating a .jamrc file in your home directory.

.jamrc

repositories

An array with Jam repositiories. Jam uses http://jamjs.org/repository by default, but it's possible to create a local, e.g. corporate, repository.

exports.repositories = [
    "http://mycorporation.com:5984/repository/",
    "http://jamjs.org/repository"
];

Repositories are in preference-order, so packages from repositories earlier in the list will be preferred over packages in repositories later in the list. However, when no package version is specified, the highest version number will be installed (even if that's not from the earliest repository).

You can add custom search URLs to repositories too:

exports.repositories = [
    {
        url: "http://mycorporation.com:5984/repository/",
        search: "http://db.com:5984/_fti/key/_design/search/something"
    },
    "http://jamjs.org/repository"
];

If your local repository doesn't implement full text search (e.g. you don't want to install couchdb lucene), you can disable searching functionality for that repository, otherwise jam search would report an error:

exports.repositories = [
    {
        url: "http://mycorporation.com:5984/repository/",
        search: false
    },
    "http://jamjs.org/repository"
];

See the section below on running your own repository.

package_dir

Sets the default package installation directory (normally uses ./jam). This is best customized in your project-level package.json file, to ensure other developers also install to the correct location.

exports.package_dir = 'libs';

Running the tests

Jam includes two test suites, unit tests (in test/unit) and integration tests (in test/integration). The unit tests are easy to run by running the test/unit.sh script, or test\unit.bat on Windows. The integration tests first require you to set up a CouchDB instance to test against (you can get a free account at IrisCouch if you don't want to install CouchDB). You then need to set the JAM_TEST_DB environment variable to point to a CouchDB database URL for testing:

Linux

export JAM_TEST_DB=http://user:password@localhost:5984/jamtest

Windows

set JAM_TEST_DB=http://user:password@localhost:5984/jamtest

Warning: All data in the test database will be deleted!

You can then run the integration tests using test/integration.sh or test\integration.bat. To run BOTH the unit and integration tests use test/all.sh or test\all.bat.

Running your own private repository or mirror

  1. Install couchdb

Mac OS X:

1. Install [Homebrew](http://mxcl.github.com/homebrew/).
2. 
brew install couchdb

Ubuntu:

apt-get install couchdb
  1. Configure your database
curl -X POST http://127.0.0.1:5984/_replicate -d '{
    "source":"http://jamjs.org/repository",
    "target":"http://localhost:5984/repository",
    "continuous":true,
    "doc_ids":["_design/jam-packages"]
    }' -H "Content-Type: application/json"

To create a mirror:

curl -X POST http://127.0.0.1:5984/_replicate -d '{
    "source":"http://jamjs.org/repository",
    "target":"repository",
    "continuous":true,
    "create_target":true
    }' -H "Content-Type: application/json"

To create an empty, private repository:

curl -X PUT http://127.0.0.1:5984/repository
  1. Edit your .jamrc file to use your new repository:
exports.repositories = [
    {
        url: "http://localhost:5984/repository",
        search: false
    },
    "http://jamjs.org/repository"
];

Adding search

  1. Install couchdb-lucene
  2. Restart couchdb.
  3. Edit your .jamrc file to allow searching on your repository:
exports.repositories = [
    {
        url: "http://localhost:5984/repository",
        search: "http://localhost:5984/_fti/local/repository/_design/jam-packages/packages/"
    },
    "http://jamjs.org/repository"
];

Publishing packages to your private repository

jam publish --repository http://localhost:5984/repository

More documentation

To learn how to create and publish packages etc, and for more info on using packages, consult the Jam documentation website.

Links

Comments
  • Honor `baseUrl`

    Honor `baseUrl`

    Most projects do not have their webroot as their project root. While you can use jam install -d path/to/dir to install packages to an arbitrary directory, you can't actually make require.js load them from the right place, as jam does not have an option to set baseUrl when writing the location field in jam.json. I'd suggest adding another flag to jam install to set this option, probably -b / --base-url.

    http://requirejs.org/docs/api.html#config-baseUrl

    As an example, let's say you run:

    jam install --package-dir www/js/jam jquery
    

    You'll get a www/js/jam/require.config.js that has:

    var jam = {
        "packages": [
            {
                "name": "jquery",
                "location": "jam/jquery",
                "main": "jquery.js"
            }
        ],
        "version": "0.1.11",
        "shim": {}
    };
    

    This is wrong in several ways.

    First off, I want location to say js/jam/jquery, but I don't have the option to do this (hence this ticket).

    But secondly, this is not a sane default. When I use the default package dir, the location field becomes jam/jquery. This implies location is composed of $PKG_DIR/$MODULE_ID, or in my case, www/js/jam/jquery. That would at least be consistent.

    opened by dsc 13
  • working with Express(node.js)

    working with Express(node.js)

    I am trying to setup with Express Framework. ( http://expressjs.com/ ). I have pre-setup my static assets folder at Root/public/ ... When I am using jam install, it creates a folder of jam under the Root.

    The problem here is my Express server can only serve the static content from Root/public folder, so my html file could not reach require.js located at Root/jam/require.js, because it is located out of the static assets folder.

    Is there a way that I could set jam install location instead of default at the Root level? I cannot find it from the doc. Help please,

    Thank you very much.

    opened by mattma 12
  • "jam install jquery" failing on Windows runnning Node v0.10.0 (seems to be happening with other node libraries too)

    I just installed Node v.0.10.0 on Windows 7, i npm -g install jamjs and then i tried using jam install jquery and it threw the following error:

    Error: TypeError: Arguments to path.resolve must be strings
        at Object.exports.resolve (path.js:116:15)
        at Object.exports.extendOptions (C:\Users\jsantaana\AppData\Roaming\npm\node
    _modules\jamjs\lib\commands\install.js:133:32)
        at C:\Users\jsantaana\AppData\Roaming\npm\node_modules\jamjs\lib\commands\in
    stall.js:97:23
        at C:\Users\jsantaana\AppData\Roaming\npm\node_modules\jamjs\lib\commands\in
    stall.js:301:13
        at C:\Users\jsantaana\AppData\Roaming\npm\node_modules\jamjs\node_modules\as
    ync\lib\async.js:677:28
        at C:\Users\jsantaana\AppData\Roaming\npm\node_modules\jamjs\lib\project.js:
    25:16
        at C:\Users\jsantaana\AppData\Roaming\npm\node_modules\jamjs\lib\utils.js:81
    :9
        at fs.js:252:14
        at C:\Users\jsantaana\AppData\Roaming\npm\node_modules\jamjs\node_modules\ri
    mraf\node_modules\graceful-fs\graceful-fs.js:90:5
        at Object.oncomplete (fs.js:93:15)
    Failed
    

    This seems to be affecting several node.js packages, and it seems to be exclusively related to v0.10.0

    opened by juuliaans 10
  • Added support for JAMRC environmental variable

    Added support for JAMRC environmental variable

    Added support for JAMRC environmental variable, that overrides the location of the .jamrc file.

    Scenario:

    I have two apps with a number of deps specified in their package.json. Each of these two apps depends on a specific repository, so I would like they don't use a shared ~/.jamrc, however I don't want to create a specific user for each of these two apps.

    jam install and jam upgrade have support for specifying the repository on the command line, but only one repository.

    I would like to be able to run:

    JAMRC=.jamrc jam upgrade
    

    in each app and make sure they use the correct repository list.

    Review on Reviewable

    opened by mkmik 8
  • Managing the require.config.js file?

    Managing the require.config.js file?

    I love the idea of JamJS but what is bothering me is that every time I add a library the require.config.js is overwritten. I can't seem to find a good strategy as to how to handle customizations to the require-config file such as baseUrl, timeout, shims and aliases for non AMD or even AMD libraries not in JamJS. Obviously I could create two separate config files one for my Jam deps and one for everything else but that just feels wrong.

    Has anyone found a more elegant solution to this problem?

    opened by eclifford 7
  • Cannot publish: Error: unauthorized

    Cannot publish: Error: unauthorized

    Hello,

    I'm trying to publish to JAM, but no luck. I've entered my credentials correctly, but it is failing. I've fiddled around with things that come to mind, but couldn't get it to work...

    $ jam publish
    Please provide credentials for: http://jamjs.org/repository
    Username: kmalakoff
    Password: 
    creating /Users/kevin/.jam/cache/knockback/0.18.0/knockback-0.18.0.tar.gz
    extracting /Users/kevin/.jam/cache/knockback/0.18.0/knockback-0.18.0.tar.gz
    Error: unauthorized
    Must be package owner
    

    The repository is here: https://github.com/kmalakoff/knockback

    Any ideas?

    Cheers!

    opened by kmalakoff 6
  • Issue publishing a package of which I am not the author

    Issue publishing a package of which I am not the author

    I reached out to the author of the jquery-validation plugin and submitted a pull request to publish to jam. He is not interested, so I figured I would add myself as a maintainer in the package.json and publish it. Needless to say, it is not working. I am getting this error:

    creating /home/wtodd/.jam/cache/jquery-validation/1.12.0pre/jquery-validation-1.12.0pre.tar.gz
    extracting /home/wtodd/.jam/cache/jquery-validation/1.12.0pre/jquery-validation-1.12.0pre.tar.gz
    modified mode 493 => 492 localization/messages_hr.js
    Error: unauthorized
    Must be package owner
    

    What am I missing?

    opened by wesleytodd 6
  • Module name “underscore” has not been loaded yet for context: _

    Module name “underscore” has not been loaded yet for context: _

    Hello,

    I've been playing with jam since few days now and got an unexpected error.

    here is my package.json file

        "jam": {
          "packageDir": "public/lib",
          "baseUrl": "public",
          "dependencies": {
            "backbone": "*",
            "jquery": "*"
          }
        }
    

    When i run my website i have no issue, all files are loaded correctly... As soon as I compile everything the browser throw this error

    Uncaught Error: Module name “underscore” has not been loaded yet for context: _
    

    my compile command is the following

    jam compile -i app -o public/lib/require.js 
    

    as soon as i run jam recompile everything works fine.

    Any idea ? Thanks for your help

    opened by mic0331 6
  • packages named 'something.js'

    packages named 'something.js'

    I am trying to publish sweet.js but it does not work correctly because this confuses require

    define(['sweet.js'], function(sweet){ })
    

    require seems to see the .js as meaning local so the package is never found.

    opened by ryanramage 5
  • Make .jamrc location more flexible

    Make .jamrc location more flexible

    It would be nice if the .jamrc file could be put inside your project directory or your home directory.

    Maybe when making a jam call it should look into the current directory for the .jamrc file and if not found recursively look into the parent directories until the file is found or defaults used.

    This would be similar to how grunt.js works for finding it's grunt config files.

    opened by pieterv 5
  • Github URLs fail to resolve in package.json dependencies list

    Github URLs fail to resolve in package.json dependencies list

    While every package doesn't register itself as Jam.js package, I appreciate the ability to install directly from GitHub. However, a gh:<user>/<repo>[/<branch>] url in the dependencies list in the package.json file fails.

    This inconsistency is very annoying and makes distributing code without including external depencies impossible. (Which is a feature that dependency managers should provide [and why I love them!]) It makes me question the whole idea of including Jam.js in the project at all, as all it really provides in this case is a partially pre-configured require.js installation. (Mind you, I am a fan of jam.js. Most of the time, it just works.)

    Example:

    Contents of package.json:

    {
        "jam": {
            "dependencies": {
                "gh:kriskowal/q": null
            }
        }
    }
    

    Output of jam install

    $ jam install
    Building version tree...
    repositories checking "gh:kriskowal/q"
    Error: No package for 'gh:kriskowal/q'
        at Object.exports.dependencyError (/usr/local/lib/node_modules/jamjs/lib/tree.js:227:16)
        at Object.exports.updateDep (/usr/local/lib/node_modules/jamjs/lib/tree.js:192:33)
        at Object.exports.addDependency (/usr/local/lib/node_modules/jamjs/lib/tree.js:139:28)
        at /usr/local/lib/node_modules/jamjs/lib/tree.js:145:32
        at /usr/local/lib/node_modules/jamjs/lib/tree.js:188:20
        at /usr/local/lib/node_modules/jamjs/lib/repository.js:460:9
        at /usr/local/lib/node_modules/jamjs/node_modules/async/lib/async.js:94:25
        at /usr/local/lib/node_modules/jamjs/lib/repository.js:456:13
        at /usr/local/lib/node_modules/jamjs/lib/repository.js:210:9
        at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/jamjs/lib/couchdb.js:248:25)
    Failed
    

    A command line install of the same repo ($ jam install gh:kriskowal/q) works as expected, so I will not include its' output.

    opened by nikcorg 4
  • Homepage seems broken

    Homepage seems broken

    On the homepage when I click certain links, instead of going to the page the homepage just reloads. For example the "Read the docs" on the homepage, just reloads the page. That is assuming there are any docs to begin with. Same goes for "Create a package". Pretty important things to read up on.

    Looking at the logs, such links do try to go to the correct url, but the server returns a HTTP 301 redirect back to the homepage. That explains the problem at least, now as for a solution?... :)

    For completeness sake, I'm on Firefox Dev 61, Windows 10.

    opened by thany 0
  • Fix bug when installing jam using NPM v3

    Fix bug when installing jam using NPM v3

    When using Jam with NPM v3, node_modules are stored at the top level, not recursively.

    e.g.

    NPM v2

    .
    └─┬ node_modules
      └─┬ jam
        └─┬ node_modules
          └── requirejs
    

    NPM v3

    .
    └─┬ node_modules
      ├── jam
      └── requirejs
    

    As such, fs.readFile('../node_modules/require/require.js', cb) should be replaced with the require syntax: require('require/require.js'), which requires the correct node module from wherever they are stored.

    opened by jpstevens 1
  • No path in the define after compile

    No path in the define after compile

    A script with a define:

    define ([
        "jquery",
        "cobweb/Basic/X3DField",
        "cobweb/Bits/X3DConstants",
    ],
    function ($, X3DField, X3DConstants)
    {
    "use strict";
    
        function SFBool (value)
        {
    ...
    

    results after 'jam compile' in a define without path in the define. All other scripts have the path in the define. This effect does not occur when the "use strict" directive is not present. The effect occurs in very seldom cases (3 of 200 files). There is no special difference between other scripts to the affected script.

    opened by create3000 0
  • Search needs improvement

    Search needs improvement

    e.g. when searching for for jquery all packages that contain jquery in some way are returned. The actual jquery package is somewhere on the fifth page or so.

    If there is a perfect match that one should be returned as first result.

    Also the sorting is weird and should not favor uppercase results before lowercase.

    opened by DanieleTorino 0
Owner
Caolan McMahon
I write JavaScript, Scheme, Python, and Rust. I enjoy good offline experiences, safely synchronising data, and implementing real-time collaboration.
Caolan McMahon
A package manager for the web

Bower - A package manager for the web ..psst! While Bower is maintained, we recommend yarn and webpack or parcel for new front-end projects! Bower off

Bower 15.1k Jan 1, 2023
📦🚀 Fast, disk space efficient package manager

中文 | Español Fast, disk space efficient package manager: Fast. Up to 2x faster than the alternatives (see benchmark). Efficient. Files inside node_mod

pnpm 21.2k Jan 3, 2023
A next-generation package manager for the front-end

Duo is a next-generation package manager that blends the best ideas from Component, Browserify and Go to make organizing and writing front-end code qu

Duo 3.4k Dec 28, 2022
Brand new static package manager.

spm Brand new static package manager for browser. spm 从 3.9 开始将不再管理组件的生命周期, 即不再有 spmjs.io. 所以相应的逻辑全部去除. 请使用 npm 来管理组件. Install $ npm install spm -g Us

Static Package Manager 907 Sep 24, 2022
interplanetary package manager

interplanetary package manager

Nathan Ginnever 10 Oct 9, 2021
This repository is moving to: https://github.com/npm/cli

We've moved! Hi! This repository is no longer being used and has been archived for historical purposes. ?? CLI Source Code & Pull Requests now live at

npm 17.4k Jan 9, 2023
the no-library library: open module JavaScript framework

ENDER Ender is a full featured package manager for your browser It allows you to search, install, manage, and compile front-end JavaScript packages an

Ender 1.8k Dec 24, 2022
The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry

Fast, reliable, and secure dependency management. Fast: Yarn caches every package it has downloaded, so it never needs to download the same package ag

Yarn 41k Jan 5, 2023
Create front end projects from templates, add dependencies, and automate the resulting projects

volo Create browser-based, front-end projects from project templates, and add dependencies by fetching them from GitHub. Once your project is set up,

volojs 1.4k Jan 2, 2023
1KB lightweight, fast & powerful JavaScript templating engine with zero dependencies. Compatible with server-side environments like node.js, module loaders like RequireJS and all web browsers.

JavaScript Templates Contents Demo Description Usage Client-side Server-side Requirements API tmpl() function Templates cache Output encoding Local he

Sebastian Tschan 1.7k Jan 3, 2023
A devtool improve your pakage manager use experience no more care about what package manager is this repo use; one line, try all.

pi A devtool improve your pakage manager use experience no more care about what package manager is this repo use; one line, try all. Stargazers over t

tick 11 Nov 1, 2022
Browser library compatible with Node.js request package

Browser Request: The easiest HTTP library you'll ever see Browser Request is a port of Mikeal Rogers's ubiquitous and excellent [request][req] package

Iris Couch 357 Nov 11, 2022
Meogic-tab-manager is an extensible, headless JavaScript tab manager framework.

MeogicTabManager English document MeogicTabManager是一个有可拓展性的、headless的JavaScript标签页管理框架。 MeogicTabManager旨在提供可自由组装页面框架、自定义页面组件、甚至覆盖框架自带事件响应的开发体验。 Meogi

meogic-tech 5 Oct 8, 2022
Package fetcher is a bot messenger which gather npm packages by uploading either a json file (package.json) or a picture representing package.json. To continue...

package-fetcher Ce projet contient un boilerplate pour un bot messenger et l'executable Windows ngrok qui va permettre de créer un tunnel https pour c

AILI Fida Aliotti Christino 2 Mar 29, 2022
Typescript package compatible with python's pickle loads/dumps

picklefriend Typescript package compatible with python's pickle loads/dumps Installation npm i picklefriend Usage import { pickle } from 'picklefriend

null 4 Oct 27, 2022
A technology stack solution using the AWS Serverless architecture.Atlas stack for building applications focused on generating value.

Atlas A technology stack solution using the AWS Serverless architecture.Atlas stack for building applications focused on generating value. Description

Atlas 9 Dec 15, 2022
EggyJS is a Javascript micro Library for simple, lightweight toast popups focused on being dependency-less, lightweight, quick and efficient.

EggyJS EggyJS is a Javascript micro Library for simple, lightweight toast popups. The goal of this library was to create something that meets the foll

Sam 10 Jan 8, 2023
frontend package manager and build tool for modular web applications

THIS PROJECT IS DEPRECATED Component is not maintained anymore. See here #639 for more information. You can still use the component registry on compon

Component 4.6k Dec 30, 2022
A package manager for the web

Bower - A package manager for the web ..psst! While Bower is maintained, we recommend yarn and webpack or parcel for new front-end projects! Bower off

Bower 15.1k Jan 1, 2023
📦🚀 Fast, disk space efficient package manager

中文 | Español Fast, disk space efficient package manager: Fast. Up to 2x faster than the alternatives (see benchmark). Efficient. Files inside node_mod

pnpm 21.2k Jan 3, 2023