1

我正在使用 yeoman 并且 grunt 构建在 requirejs:dist 失败,并出现错误“加载器插件未在构建中调用加载回调:文本”。

我在这里看到了这个问题,但更新 requirejs 并没有帮助我。下面的控制台输出:

    PS D:\...> bower -version
    1.2.7
    PS D:\...> npm -version
    1.3.11
    PS D:\...> bower ls
    bower check-new     Checking for new versions of the project dependencies..
    html-console#0.0.0 D:\...
    +-- backbone#1.1.0
    +-- bootstrap#3.0.1
    ¦ +-- jquery#2.0.3
    +-- jquery#2.0.3
    +-- modernizr#2.6.2
    +-- requirejs#2.1.9
    +-- requirejs-text#2.0.10
    +-- sass-bootstrap#3.0.1
    ¦ +-- jquery#2.0.3
    +-- underscore#1.5.2
    PS D:\...> npm ls | grep require
    ????????? grunt-bower-requirejs@0.7.1
    ??? ????????? requirejs@2.1.9
    ????????? grunt-requirejs@0.4.0
    ??? ????????? requirejs@2.1.9
    PS D:\...> grunt build
    Running "clean:dist" (clean) task
    Cleaning .tmp...OK

    Running "coffee:dist" (coffee) task

    Running "coffee:test" (coffee) task

    Running "createDefaultTemplate" task

    Running "jst:compile" (jst) task
    >> Destination not written because compiled files were empty.

    Running "compass:dist" (compass) task
    directory .tmp/styles/
       create .tmp/styles/login-reg.css (0.029s)
       create .tmp/styles/main.css (1.796s)
    Compilation took 1.83s

    Running "useminPrepare:html" (useminPrepare) task
    Going through app/index.html to update the config
    Looking for build script HTML comment blocks

    Found a block:
            <!-- build:css(.tmp) styles/main.css -->
            <link rel="stylesheet" href="styles/main.css">
            <link rel="stylesheet" href="styles/login-reg.css">
            <!-- endbuild -->
    Updating config with the following assets:
        - .tmp\styles\main.css
        - .tmp\styles\login-reg.css

    Found a block:
            <!-- build:js scripts/vendor/modernizr.js -->
            <script src="bower_components/modernizr/modernizr.js"></script>
            <!-- endbuild -->
    Updating config with the following assets:
        - app\bower_components\modernizr\modernizr.js

    Found a block:
            <!-- build:js scripts/main.js -->
            <script data-main="scripts/main" src="bower_components/requirejs/require.js"></script>
            <!-- endbuild -->
    Updating config with the following assets:
        - dist\scripts\main.js

    Configuration is now:

      cssmin:
      { dist:
       { files:
          { '<%= yeoman.dist %>/styles/main.css':
             [ '.tmp/styles/{,*/}*.css',
               'app/styles/{,*/}*.css' ] } },
      'dist\\styles\\main.css': 'dist\\styles\\main.css' }

      concat:
      { 'dist\\styles\\main.css':
       [ '.tmp\\styles\\main.css',
         '.tmp\\styles\\login-reg.css' ],
      'dist\\scripts\\vendor\\modernizr.js': [ 'app\\bower_components\\modernizr\\modernizr.js' ],
      'dist\\scripts\\main.js': [ 'dist\\scripts\\main.js' ] }

      uglify:
      { 'dist\\scripts\\vendor\\modernizr.js': 'dist\\scripts\\vendor\\modernizr.js',
      'dist\\scripts\\main.js': 'dist\\scripts\\main.js',
      'dist\\bower_components\\requirejs\\require.js': 'app\\bower_components\\requirejs\\require.js' }

      requirejs:
      { dist:
       { options:
          { baseUrl: 'app/scripts',
            optimize: 'none',
            paths: { templates: '../../.tmp/scripts/templates' },
            preserveLicenseComments: false,
            useStrict: true,
            wrap: true,
            name: 'main',
            out: 'dist\\scripts\\main.js',
            mainConfigFile: 'app\\scripts\\main.js' } } }

    Running "requirejs:dist" (requirejs) task
    >> Error: Error: Loader plugin did not call the load callback in the build: text
    >> Module loading did not complete for: main, app, router, views/users/register, text!/templates/unauthd/register.html,
    views/users/forgotpassword, text!/templates/unauthd/forgotpassword.html
    >> The following modules share the same URL. This could be a misconfiguration if that URL only has one anonymous module
    in it:
    >> undefined: text!/templates/unauthd/register.html, text!/templates/unauthd/forgotpassword.html
    >>     at Function.build.checkForErrors (D:\...\node_modules\grunt-requirejs\node_modules\requirejs\bin\r.js:25510:19)
    Warning: Task "requirejs:dist" failed. Use --force to continue.

    Aborted due to warnings.

    Elapsed time
    loading tasks       2s
    jst:compile         24ms
    compass:dist        2s
    useminPrepare:html  63ms
    requirejs:dist      528ms
    Total               5s
    PS D:\...>
4

1 回答 1

1

r.js 版本 2.1.10 改进了错误报告。您可能会像我一样发现您的补充 HTML 文件(register.html 和 forgotpassword.html)并未像您希望的那样被复制到 .tmp。我现在正在解决配置问题,但是让主干视图加载没有替换的 ejs 可能更容易。

于 2014-03-09T16:59:58.407 回答