Open mduman opened 9 years ago
What is your require.js configuration and directory structure?
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
});
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
i'm seeing something similar. using grunt-contrib-requirejs 0.4.4
You have to rename hbs.js to something else. That fixed for me.
@luos i have no hbs.js file.
perhaps the hbs plugin is failing to load?
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.
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?
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
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);
}
}
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.
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.
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