1

私は yeoman を使用していますが、requirejs:dist で grunt ビルドが失敗し、「ローダー プラグインはビルドでロード コールバックを呼び出しませんでした: テキスト」というエラーが表示されます。

ここで質問を見ましたが、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 と forgetpassword.html) が、希望どおりに .tmp にコピーされていないことに気付くでしょう。現在、そのための構成の問題に取り組んでいますが、バックボーン ビューに置換のない ejs をロードさせる方がおそらく簡単です。

于 2014-03-09T16:59:58.407 に答える