5

Hello I am using yo ko a knockout yeoman generator in my application. The application has been scaffold with requirejs and gulp, but I am having trouble adding ForerunnerDB to the require.config for distribution, here is the require.config.js:

//require.js looks for the following global when initializing
var require = {
    baseUrl: ".",
    paths: {
        "bootstrap":            "bower_modules/components-bootstrap/js/bootstrap.min",
        "crossroads":           "bower_modules/crossroads/dist/crossroads.min",
        "hasher":               "bower_modules/hasher/dist/js/hasher.min",
        "jquery":               "bower_modules/jquery/dist/jquery",
        "knockout":             "bower_modules/knockout/dist/knockout",
        "knockout-projections": "bower_modules/knockout-projections/dist/knockout-projections",
        "signals":              "bower_modules/js-signals/dist/signals.min",
        "text":                 "bower_modules/requirejs-text/text",
        'forerunner': 'bower_modules/forerunnerdb/js/dist/fdb-all.min'
    },
    shim: {
        "bootstrap": { deps: ["jquery"] }
    }
};

I am using the gulpfile.js with gulp:serve:dist but I am getting

[Error: Error: ENOENT: no such file or directory, open 'c:...\temp\core.js'

In module tree: app/startup forerunner at Error (native)

But everything is working when I use gulp serve:src. I already tried to add core.js dependencies in the shim, but can not make it work. There is always a file missing .

here is the github repo

Community
  • 1
  • 1
jean Pokou
  • 679
  • 5
  • 18
  • Have you checked that the file at that path exists? If it does, make sure nothing is locking that file (reboot). Windows fs locks are the worst and they should be ashamed. – micah Jun 08 '16 at 16:30
  • Yes it does exist and I did tried on my ios, I am able to pass the core js when adding deps to the shim but I get stuck the file 'Overload.js' which exist also but return ENOENT – jean Pokou Jun 08 '16 at 16:33
  • Where is core.js coming from? It's not part of ForerunnerDB... – Rob Evans Jun 09 '16 at 09:06
  • it is part of ForerunnerDB – jean Pokou Jun 09 '16 at 11:38
  • Oh I see... I think I know which core.js it is referring to. I was thrown because you are including fdb-all.min.js which means that you are using a pre-built file, but it seems like your build script is trying to re-compile ForerunnerDB via the "browserify": "./js/builds/all build" file or the "main": "./js/builds/nodecore" (both in package.json). Is some part of this system reading the package.json and trying to compile ForerunnerDB itself? – Rob Evans Jun 15 '16 at 09:48
  • I am using gulp-requirejs-bundler to discovers all AMD dependencies, concatenates together all required .js files you can see in the gulp file, Is it possible to have Forrunner as a single file with all the plugins and tools – jean Pokou Jun 15 '16 at 12:51
  • This may be unrelated bug, but I'll link it because this is too about ENOENT, shim and requirejs (https://github.com/requirejs/r.js/issues/831). Are you using define in your require.js definitions? – mico Jun 16 '16 at 03:45
  • @jeanPokou The bower_modules/forerunnerdb/js/dist/fdb-all.min file is a single file with all the plugins, pre-built. It has a UMD wrapper allowing both commonJS and RequireJS to load it. If you comment out ONLY the ForerunnerDB line from your paths object, do you still get the error or not? – Rob Evans Jun 16 '16 at 12:16
  • When I comment out the line ForunnerDB, and I comment out all the call of ForerunnerDB I get no error – jean Pokou Jun 16 '16 at 12:39

2 Answers2

1

For some reason requirejs gets upset in this configuration so the way to solve it is to add ForerunnerDB to your index.html as a separate script, remove all the dependency references to ForerunnerDB in your require.config.js and then modify your gulp default task to concatenate the scripts.js file that gets generated with the fdb-all.min.js file in ForerunnerDB's js/dists folder.

I have updated the github repo with the changes you have to make as described above. You can see them here: https://github.com/jeanPokou/project_beta/commits/master

Rob Evans
  • 6,750
  • 4
  • 39
  • 56
-1

When you tried with the shim are you sure you wrote it the right way ?

var require = {
    baseUrl: ".",
    paths: {
        "corejs":                 "bower_modules/...",
        'forerunner': 'bower_modules/forerunnerdb/js/dist/fdb-all.min'
    },
    shim: {
        "corejs": { deps: ["forerunner"] }
    }
};
François Richard
  • 6,817
  • 10
  • 43
  • 78