• Stars
    star
    295
  • Rank 140,902 (Top 3 %)
  • Language
    Clojure
  • Created almost 12 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Manage Node dependencies for CLJS projects

lein-npm Build Status

Leiningen plugin for enabling Node based ClojureScript projects.

Installation

To enable lein-npm for your project, put the following in the :plugins vector of your project.clj file:

[lein-npm "0.6.2"]

Managing npm dependencies

You can specify a project's npm dependencies by adding an :npm map to your project.clj with a :dependencies or :devDependencies key. These correspond to the "dependencies" and "devDependencies" keys in a package.json file.

:npm {:dependencies [[underscore "1.4.3"]
                     [nyancat "0.0.3"]
                     [mongodb "1.2.7"]
                     ;; Other types of dependencies (github, private npm, etc.) can be passed as a string
                     ;; See npm docs though as this may change between versions.
                     ;; https://docs.npmjs.com/files/package.json#dependencies
                     [your-module "github-username/repo-name#commitish"]]}

These dependencies, and any npm dependencies of packages pulled in through the regular :dependencies, will be installed through npm when you run either lein npm install or lein deps.

Transitive dependencies

lein-npm looks at your project's dependencies (and their dependencies, etc) to check if there are any NPM libraries in :dependencies in the project.clj to install. Your testing and development libraries should go into :devDependencies. The only things that should go into :dependencies are NPM dependencies that are required for people to use your library.

Invoking npm

You can execute npm commands that require the presence of a package.json file using the lein npm command. This command creates a temporary package.json based on your project.clj before invoking the npm command you specify. The keys name, description, version and dependencies are automatically added to package.json. Other keys can be specified in your project.clj at :package under :npm.:

  :npm {:package {:scripts {:test "testem"}}}
$ lein npm install        # installs project dependencies
$ lein npm ls             # lists installed dependencies
$ lein npm search nyancat # searches for packages containing "nyancat"

Bower dependencies

lein-bower is a related Leiningen plugin that performs the same service for Bower dependencies. lein-bower itself depends on lein-npm.

Running ClojureScript apps

The plugin installs a lein run hook which enables you to specify a JavaScript file instead of a Clojure namespace for the :main key in your project.clj, like this:

:main "js/main.js"

If :main is a string that refers to a file that exists and ends with .js, it will launch this file using npm start, after first running npm install if necessary. Any command line arguments following lein run will be passed through to the Node process. Note that a scripts.start record will be automatically added to the generated package.json file, simply containing node <value of :main>, but you can override this using the :package key under :npm as described above. The :main key will still have to exist and point to a file ending in .js, though, or lein run will stay with its default behaviour.

Changing the directory used

npm does not allow you to put stuff anywhere besides node_modules, even if that name is against your religion, however, you can change the root used by lein-npm to be something other than your project root like this:

:npm {:root "resources/public/js"}

Or you can use a keyword to look the path up in your project map:

:npm {:root :target-path}

License

Copyright 2012 Bodil Stokke

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

incise

An extensible static site generator written in Clojure.
Clojure
32
star
2

manners

A validation library built on using predicates properly.
Clojure
23
star
3

Cadence

A web application demoing the intended use case of Cadence.js, authentication.
Clojure
14
star
4

Bits-Books

A Flask front-end to fictional book selling eCommerce website.
Python
12
star
5

fixturex

A library of helpful test fixture macros and functions for when namespace level fixtures with `use-fixtures` is not specific enough.
Clojure
8
star
6

Cadence-js

A typing style monitor for input fields built as a jQuery plugin.
JavaScript
7
star
7

dmenu

A fork of dmenu which adds some flags I use.
C
6
star
8

chic-text

A Clojure text formatting library for the console.
Clojure
6
star
9

vim-autornu

An opinionated fork of the wonderful numbers.vim.
Vim Script
5
star
10

Mr-Repo

A simple repo management system.
Python
5
star
11

center_dmenu

A simple script that makes dmenu launch in the center of the screen.
Python
4
star
12

sally

Static Analysis live!
Clojure
2
star
13

Clojure-Vim-Demo

A very simple project to help me show off Vim & Clojure trying to work together.
Clojure
2
star
14

vim-textobj-dash

Dash text-object for Vim
Vim Script
2
star
15

git-fyncy

The funky git aware remote syncer.
Ruby
2
star
16

dpi.py

A simple python script for helping me determine the pixel density of various monitors.
Python
2
star
17

ryanmcg.github.io

My website, static html
CSS
2
star
18

dotfiles

Dotfiles I use on various personal computers.
C
2
star
19

slimVimClojure

A fork of a fork of Slimv that replaces the Clojure syntax and indent files with the ones from Vimclojure (forked from sjl on bitbucket).
Common Lisp
2
star
20

incise-example-project

An example project for incise (a static site generator written in Clojure).
Clojure
2
star
21

incise-codox

An incise plugin which adds easy support for codox.
Clojure
1
star
22

authorate

A command line based tool to classify snippets of text as like another group of snippets.
Python
1
star
23

incise-stefon

An couple of extensions to incise adding support for stefon.
Clojure
1
star
24

vim-swapnumbers

Swap the numbers on your keyboard with symbols in insert mode!
Vim Script
1
star
25

lein-incise

A Leiningen plugin to make running incise methods easier.
Clojure
1
star
26

edfp

A visual-editor based command line tool for manipulating files.
Rust
1
star
27

lace

Lace your commands.
Shell
1
star
28

Slidecase

WordPress CMS Plugin - A dynamic jQuery based Carousel
JavaScript
1
star
29

speclj.shoulds.matrix

Custom should(s) for clojure.core.matrix comparisons.
Clojure
1
star
30

vim-guifontzoom

Easily increase and decrease guifont's size in gvim.
Vim Script
1
star
31

semaphore-js

Sometimes you only want to do things one at a time.
JavaScript
1
star
32

majumble

A quick and dirty matrix manipulation postfix language.
Clojure
1
star
33

vim-j

VIM runtime files for J
Vim Script
1
star
34

incise-git-deployer

The default markdown parser included in incise.
Clojure
1
star
35

CloudUnApp

A shell script that uses a few command line utilities to emulate CloudApp's behavior.
Shell
1
star
36

vm-assets

JS and CSS assets for my personal websites
CSS
1
star
37

Tabbox

Wordpress plugin to display posts in jquery powered side-bar tabbed box.
PHP
1
star
38

secretsanta

OMG why do I have to write this
Python
1
star
39

columbus-clojure.demo.reducers

Benchmarking various versions of reduce/fold for the Columbus Clojure meetup.
Clojure
1
star
40

dataserv-client-docker

Dockerfile for dataserv-client. http://driveshare.org/dataserv.html
1
star
41

personal-resume

Not a library, but my personal rΓ©sumΓ© written in latex by a latex novice.
TeX
1
star
42

incise-core

The heart of incise. No batteries.
Clojure
1
star
43

reapo

A simple tool for creating remote repositories over ssh.
Python
1
star