UNPKG

1.66 kBMarkdownView Raw
1jspm is primarily a browser package manager, but there are massive benefits to enabling workflows that allow the same JavaScript code to run in both the browser and Node. As such, jspm also enables some basic usage on the server as well.
2
3**It is advisable not to use jspm for arbitrary server applications currently** as there are two major issues with Node module npm support that are limiting use of jspm in Node:
4
51. Browserify transforms support (https://github.com/jspm/npm/issues/10)
62. Packages with a `browser` field will always use that browser mapping even in Node (https://github.com/jspm/npm/issues/32), pending [conditional loading support in SystemJS](https://github.com/systemjs/systemjs/issues/285).
7
8### jspm run
9
10`jspm run` allows the immediate execution of any module from the command-line:
11
12```
13 jspm install fs
14 echo "import fs from 'fs';\
15 console.log(fs.readFileSync('package.json')+'');" > test.js
16 jspm run test
17```
18
19### jspm.import
20
21Just like `jspm run`, the [jspm API provides an import function](api.md#import) with the same functionality.
22
23### Node Core and Browserify support
24
25All Node core modules are available in the jspm registry and can be installed by their names.
26
27This includes: assert, buffer, child_process, cluster, console, constants, crypto, dgram, dns, domain, events, fs, http, https, net, os, path, process, punycode, querystring, readline, repl, stream, string_decoder, timers, tls, tty, url, util, vm, zlib.
28
29When running in Node, they use their native implementations, and when running the browser, the [Browserify core shims](https://github.com/substack/node-browserify#compatibility) are used instead.