Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requirejs build failure #216

Open
mduman opened this issue Dec 7, 2014 · 12 comments
Open

requirejs build failure #216

mduman opened this issue Dec 7, 2014 · 12 comments

Comments

@mduman
Copy link

mduman commented Dec 7, 2014

Hello,

i could not manage to build my app with r.js. (it works fine witjhout build)

versions:
"requirejs": "~2.1.15",
"handlebars": "~2.0.0",
"require-handlebars-plugin": "~0.11.1"

Could you help about the below error message please?

[18:19:08] Error: Error: ENOENT, no such file or directory 'B:_prod\app\hbs.js'

In module tree:
modules/book
modules/book/views

at Object.fs.openSync (fs.js:438:18)

at B:\node_modules\requirejs\bin\r.js:25976:19
at B:\node_modules\requirejs\bin\r.js:3005:39
at B:\node_modules\requirejs\bin\r.js:2945:25
at Function.prim.nextTick (B:\node_modules\requirejs\bin\r.js:25806:9)
at Object.p.errback (B:\node_modules\requirejs\bin\r.js:2944:26)
at Object.p.callback (B:\node_modules\requirejs\bin\r.js:2930:23)
at Object.p.promise.then (B:\node_modules\requirejs\bin\r.js:2984:23)
at build (B:\node_modules\requirejs\bin\r.js:25933:12)
at runBuild (B:\node_modules\requirejs\bin\r.js:27859:17)
at Object.context.execCb (B:\node_modules\requirejs\bin\r.js:1898:33)
@Dremora
Copy link
Contributor

Dremora commented Dec 10, 2014

What is your require.js configuration and directory structure?

@adamgruber
Copy link

I'm having a similar issue trying to build my app. Getting this error when trying to build:
Error: Error: ENOENT, no such file or directory '/Users/adamgruber/Sites/agg/dist/hbs.js

RequireJS Config:

/*global requirejs */
requirejs.config({
  baseUrl: '',
  paths: {
    jquery:              ['../bower_components/jquery/dist/jquery', '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery'],
    backbone:            '../bower_components/backbone/backbone',
    underscore:          '../bower_components/underscore/underscore',
    slick:               '../bower_components/slick.js/slick/slick',
    velocity:            '../bower_components/velocity/velocity',
    hbs:                 '../bower_components/require-handlebars-plugin/hbs',
    handlebars:          '../bower_components/require-handlebars-plugin/hbs/handlebars',
    PortfolioView:       'js/views/PortfolioView',
    ProjectView:         'js/views/ProjectView',
    PortfolioCollection: 'js/models/PortfolioCollection',
    ProjectModel:        'js/models/ProjectModel'
  },
  shim: {
    slick:    ['jquery'],
    velocity: ['jquery']
  },
  hbs: {
    helpers:           false,
    i18n:              false,
    templateExtension: 'mu',
    partialsUrl:       'views/templates'
  }
});

Directory Structure (trimmed a bit for clarity):

.
├── app.js
├── bin
├── bower_components/
│   ├── backbone/
│   ├── bootstrap/
│   ├── fontawesome/
│   ├── jquery/
│   ├── require-handlebars-plugin/
│   ├── requirejs/
│   ├── slick.js/
│   ├── underscore/
│   └── velocity/
├── node_modules/
├── build.js
├── dist/
├── public/
│   ├── favicon.ico
│   ├── fonts/
│   ├── images/
│   ├── js/
│   │   ├── home.js
│   │   ├── main.js
│   │   ├── models
│   │   │   ├── PortfolioCollection.js
│   │   │   └── ProjectModel.js
│   │   ├── modernizr.min.js
│   │   ├── requirejs.conf.js
│   │   └── views
│   │       ├── PortfolioView.js
│   │       └── ProjectView.js
│   └── stylesheets/
├── router.js
├── routes/
├── source/
├── source-images/
└── views/
    ├── 404.mu
    ├── error.mu
    ├── index.mu
    ├── layouts/
    │   └── default.mu
    ├── partials/
    │   ├── _about.mu
    │   ├── _footer.mu
    │   ├── _intro.mu
    │   ├── _navbar.mu
    │   ├── _portfolio.mu
    │   └── _resume.mu
    └── templates/
        └── _project.mu

And here's the file where I'm using the hbs plugin:

define([
  'backbone',
  'hbs!templates/_project',
  'jquery'
], function(Backbone, ProjectTemplate, $) {
// more code here
});

@morficus
Copy link

morficus commented Mar 2, 2015

Running in to the same issue. At first blush it seems like an issue with having a file called hbs.js and a directory called hbs at the same level.

@adamgruber did you ever find a solution?

edit:
using require-handlebars-plugin 0.11.2
require.js 2.1.15
and grunt-requirejs 0.4.2

@mattkime
Copy link

i'm seeing something similar. using grunt-contrib-requirejs 0.4.4

@luos
Copy link

luos commented Mar 17, 2015

You have to rename hbs.js to something else. That fixed for me.

@mattkime
Copy link

@luos i have no hbs.js file.

perhaps the hbs plugin is failing to load?

@mattkime
Copy link

it seems the hbs.js file was not being copied although the hbs dir was. i'm not familiar enough with requirejs to say why this would occur.

@mattkime
Copy link

this issue appears to be resolved in a newer version of requirejs. i saw the problem under 2.1.11 but its gone under 2.1.16

@mduman can you confirm?

@mattkime
Copy link

i lied. its still there.

i think the problem is that there is both an hsb dir and hbs file. the problem is only shown when the content for this project is outside your base dir

@mattkime
Copy link

my bower content is not within my requirejs base directory, therefore the build fails due to the following lines of code.

the fix - don't have hbs.js and the hbs dir.

//Skip empty: paths
if (srcPath !== 'empty:') {
    //If the srcPath is a directory, copy the whole directory.
    if (file.exists(srcPath) && file.isDirectory(srcPath)) {
        //Copy files to build area. Copy all files (the /\w/ regexp)
        file.copyDir(srcPath, destPath, /\w/, true);
    } else {
        //Try a .js extension
        srcPath += '.js';
        destPath += '.js';
        file.copyFile(srcPath, destPath);
    }
}

@adamgruber
Copy link

I took another look at this but still no luck. Definitely seems to be an issue with the mix of hbs.js and the hbs directory. At this point I'm looking into precompiling templates using a gulp task and requiring that file.

@mattkime
Copy link

mattkime commented Apr 6, 2015

after some further investigation i think the best solution is to make hbs.js rely on externally available modules rather than attempt to supply its own. it would also be good to reduce the number of dependencies - the i18n bits should be removed and reliance on underscore could be refactored out. Handlebars would still need to be supplied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants