2017-01-03 6 views
0

私のプロジェクトでビジュアルスタジオでgulpを使用しています。2013年ガルプのエラー - 'パスが指定されていません!親戚を得ることはできません。

すべてのプロジェクトを新しいdev-machineに移動しました。私はgulpを使用しています。ここgulpfile.jsの私の仕事は、次のとおりです。

config = { 
     scripts: { 
      src: "./app", 
      destination: "./scripts/app" 
     }, 
     templates: { 
      src: "./app/**/*.tmpl.html", 
      destination: "./scripts/app", 
      filename: "templates" 
     }, 
     build: { 
      src: "./scripts/app/*.js", 
      destination: "./scripts/build", 
      filename: "dashboard-build" 
     } 
    } 

    gulp.task("templates", function() { 
    gulp.src(config.templates.src) 
     .pipe(html2js({ 
      outputModuleName: "templates", 
      useStrict: true 
     })) 
     .pipe(concat(config.templates.filename + ".js")) 
     .pipe(gulp.dest(config.templates.destination)) 
}); 

私はこのエラーを取得タスクコマンドプロンプトウィンドウを起動してみてください。私の古いマシン上のすべてが完璧に働いている間

C:\Development\Repositories\Tambaound\Tambaound.Web>gulp templates 
[17:04:59] Using gulpfile C:\Development\Repositories\Tambaound\Tambaound.Web\gulpfile.js 
[17:04:59] Starting 'templates'... 
[17:04:59] Finished 'templates' after 12 ms 
C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\gulp-util\node_modules\vinyl\index.js:120 
    if (!this.path) throw new Error('No path specified! Can not get relative.'); 
        ^

Error: No path specified! Can not get relative. 
    at File.get (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\gulp-util\node_modules\vinyl\index.js:120:27) 
    at Stream.bufferContents (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-concat\index.js:35:20) 
    at Stream.stream.write (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-concat\node_modules\through\index.js:26:11) 
    at DestroyableTransform.ondata (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:531:20) 
    at emitOne (events.js:96:13) 
    at DestroyableTransform.emit (events.js:188:7) 
    at readableAddChunk (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:198:18) 
    at DestroyableTransform.Readable.push (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:157:10) 
    at DestroyableTransform.Transform.push (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:123:32) 
    at DestroyableTransform._flush (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\index.js:75:14) 

および他のすべてのタスクを新しいdevマシンでうまく動作します。

問題の解決方法を教えてください。

答えて

2

これらの2台のマシンで異なるバージョンのgulp-html2jsを使用している可能性があります。非常にあなたが使用しようとしているコードのように見える

gulp.src('templates/*.html') 
    .pipe(html2js({ 
    outputModuleName: 'template-test', 
    useStrict: true, 
    target: 'js' 
    })) 

以下はgulp-html2jsREADME.md for v0.3.1からまっすぐ撮影した例です。

gulp.src('templates/*.html') 
    .pipe(html2js('angular.js', { 
    adapter: 'angular', 
    base: 'templates', 
    name: 'angular-demo' 
    })) 

お知らせ違い:

しかし、ここでREADME.md for v0.4.2(最新版)から取られた同じ例ですか? ouputModuleNameオプションはnameに名前が変更されたようです。 html2js()の最初のパラメータも、新しいモジュールのファイル名になりました。あなたのコードにはそれがありません。それはあなたにNo path specified!エラーを与えるものです。

通常、このようなことは起こりません。モジュールはSemantic Versioningに従うべきであり、このような急な変更はメジャーバージョンの変更でのみ導入されるべきです。しかしis exempt from this ruleをv0.x.x:

  1. はあなたが古いマシンに持ってgulp-html2jsの同じバージョンをインストールしていることを確認してください:

    Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable.

    あなたは2つのオプションがあります。 v0.3.1を使用すると、それを実行する必要があります。

    npm install --save-dev [email protected] 
    
  2. は上記のバージョン0.4.2のための例では1に見えるようにあなたのタスクを調整します。 README for that versionがそれを手助けするでしょう。

(あなたも同じタスクをやっているように見えるが、約3倍のダウンロードを持っている競合のプラグインである、代わりにgulp-ng-html2jsを使用してに見たいと思うかもしれません。)

関連する問題