4

I'm trying to understand how executables can be run after installing a module using the JSPM. For instance if I run jspm install gulp, then I would expect to be able to run the following command:

./jspm_packages/npm/gulp\@3.8.11/bin/gulp.js

Actually it would be better if jspm would handle this so that there is a hidden bin directory containing all retrieved executables (such as gulp) at the following location:

./jspm_packages/.bin

That way I could just have a single addition to my PATH environment variable that would allow these executables to run.

Currently when I attempt to run a jspm-installed gulp, I get the following error message:

[jspm-test]$ ./jspm_packages/npm/gulp\@3.8.11/bin/gulp.js 
./jspm_packages/npm/gulp@3.8.11/bin/gulp.js: line 1: /bin: Is a directory
./jspm_packages/npm/gulp@3.8.11/bin/gulp.js: line 2: syntax error near unexpected token `('
./jspm_packages/npm/gulp@3.8.11/bin/gulp.js: line 2: `(function(process) {'

Is there some other way I should be going about this?

2 Answers2

0

In my experience this is weird with JSPM as JSPM is more geared towards deps for your app that are actually in production in the browser. What I do in my projects is install modules I need to run with scripts/in dev (gulp, karma, express etc) using NPM, then you can run them with node:

node ./node_modules/karma/bin/karma.js <args>

It's kind of weird, but if you think of it as NPM handling local, "executable" deps that aren't used in production and JSPM handling the deps for your application that are going to get bundled and shipped it makes sense.

SleepyProgrammer
  • 443
  • 1
  • 5
  • 15
0

I agree with @SleepyProgrammer response.

JSPM is a package manager specifically for front-end dependencies, much like bower.

It is odd to install gulp with the front-end dependencies of your project.
You'd rather install gulp, karma, express and the likes with npm as dev dependencies, to bundle and process things on your local dev server, then serve the result as js, css, html files...

a simple $(npm bin)/gulp -v make

That being said, I installed enzyme with jspm for my tests to be able to import it.


If you want to use jspm in your node projects, you can always use this command:

jspm run script

See documentation: http://jspm.io/docs/nodejs-usage.html

GBL
  • 386
  • 4
  • 13