0

I'm having a difficult time getting the jspm_packages to work correctly in my jspm configuration in my packages.json. I'm writing an app in EM6 (babel engine).

I have a gulp file that places my ES6 javascript to a folder called .tmp/scripts:

gulp.task('transpile:app', ['templates'], function() {
  return gulp.src('app/scripts/**/*.js')
    .pipe($.babel({ sourceMap: true }))
    .pipe(gulp.dest('.tmp/scripts'));
});

And then a bundle task that is supposed to convert the files in .tmp into a folder called dist:

// Bundle javascripts
gulp.task('bundle:app', function() {
  return gulp.src('')
    .pipe($.shell('jspm bundle-sfx app dist/scripts/app.js --minify --skip-source-maps'));
});

This is where is fails.

Running jspm bundle-sfx app dist/scripts/app.js --minify --skip-source-maps' prompts this error:

warn jspm_packages must be specified in the package.json within the baseURL for paths to resolve correctly.
     Building the single-file sfx bundle for app...

err  Error: ENOENT, open '/Users/connorblack/git/**********/jspm_packages/github/marionettejs/backbone.marionette@2.4.2.js'
         at Error (native)

The odd thing is that this file path for jspm_packages is looking two directories above where it should be, thus prompting the ENOENT error.

I dove a little into the docs, and found that you can set a "packages" attribute in your package.json, which is what I have done, and this is what my current file looks like:

...
"jspm": {
    "directories": {
      "baseURL": ".tmp/scripts",
      "lib": "app",
      "packages": "jspm_packages"
    },
...

I've tried multiple variations, but they all end up with a similar error. Prefixing ../../ steps further up my file system, but since the command is already looking two directories above, this doesn't help.

As you would expect, removing the attribute entirely from my package.json removes the warning and changes the ENOENT:

     Building the single-file sfx bundle for app...

err  Error: ENOENT, open '/Users/connorblack/git/********/*********/skeleton/.tmp/scripts/jspm_packages/github/marionettejs/backbone.marionette@2.4.2.js'
         at Error (native)

where it now appears to be looking for the jspm_packages folder below my baseURL (.tmp/scripts), which is where my gulp process places my app's scripts before converting from ES6 to normal JS.

I'm at my wit's end here. I can't seem to get the jspm process to correctly find the jspm_packages and thus I can't compile my app.

Any help would be greatly appreciated.

Connor Black
  • 6,921
  • 12
  • 39
  • 70

1 Answers1

1

I was getting a similar problem, when I was trying

jspm bundle app.js app/app.bundle.js 

But I then changed

  "jspm": {
    "directories": {
      "baseURL": "app",
      "packages": "jspm_packages"
    },

to this ..

  "jspm": {
    "directories": {
      "baseURL": "app",
      "packages": "app/jspm_packages"
    },

and the bundling started to work ...

judek
  • 313
  • 2
  • 8