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

Error: TypeError: Cannot call method 'charAt' of undefined #576

Closed
oddjobsman opened this issue Dec 3, 2013 · 3 comments
Closed

Error: TypeError: Cannot call method 'charAt' of undefined #576

oddjobsman opened this issue Dec 3, 2013 · 3 comments
Milestone

Comments

@oddjobsman
Copy link

Installed npm

npm install -g r.js

r.js versions

r.js: 2.1.9, RequireJS: 2.1.9, UglifyJS2: 2.4.0, UglifyJS: 1.3.4

grunt-cli v0.1.11
grunt v0.4.2
node.js v0.10.21
Mac OSX 10.9

My Directory structure:

.
|____package.json
|____build.js
|____public
| |____app.js
|____temp
| |____edit
| |____js
| | |____app
| | | |____app.js
| | |____main.js
| | |____vendor
| | | |____backbone-min.js
| | | |____backbone.js
| | | |____dust-core-0.3.0.js
| | | |____dust-core-0.3.0.min.js
| | | |____dust-helpers-1.1.1.js
| | | |____jquery-migrate.js
| | | |____jquery-migrate.min.js
| | | |____jquery.js
| | | |____jquery.min.js
| | | |____underscore-min.js
| | | |____underscore.js

My build.js:

({
  baseUrl: "temp/js",
  mainConfigFile: "temp/js/main.js",
  modules: ["app"],
  dir: "public/js"
})

Contents of temp/js/main.js:

(function () {
  'use strict';

  requirejs.config({
    baseUrl: 'js',
    paths: {
      'jquery': 'vendor/jquery.min',
      'underscore': 'vendor/underscore-min',
      'backbone': 'vendor/backbone-min',
      'dustjs': 'vendor/dust-core-0.3.0',
      'dustHelpers': 'vendor/dust-helpers-1.1.1'
    },
    shim: {
      underscore: {
        exports: '_'
      },
      backbone: {
        deps: ['jquery', 'underscore'],
        exports: 'Backbone'
      },
      dustjs: {
        exports: 'dust'
      },
      dustHelpers: {
        deps: ['dustjs']
      }
    }
  });

})();

I see this error when I run r.js:

$ r.js -o build.js
Error: TypeError: Cannot call method 'charAt' of undefined
    at Object.exports.normalize (path.js:336:27)

Not sure what is wrong. Is it due to an issue in the way I have setup my project. If so, please help me with suggestions to fix it.

Thanks.

@jrburke
Copy link
Member

jrburke commented Dec 31, 2013

In the build.js, looks like the modules property is not correctly specified. I expect this to work better:

modules: [{
  name: "app"
}],

@jrburke jrburke closed this as completed Dec 31, 2013
@fbiville
Copy link

Would you think it'd be possible to add an explicit check on this with a more explicit error message?

@listenrightmeow
Copy link

Can we please get a more explicit check on this issue? When the key is not defined as 'name' in the modules array object, the error is extremely mis-leading.

@jrburke jrburke added this to the 2.1.21 milestone Nov 16, 2015
@jrburke jrburke reopened this Nov 16, 2015
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

4 participants