2017-01-21 6 views
0

I'm trying to run gulp to build my app like Rob Dodson explains hereが、私は次のエラーを取得する:ポリマー:ビルド時に一気エラー:マージ・ストリーム

module.js:327 
    throw err; 
    ^Error: Cannot find module 'merge-stream' 
    at Function.Module._resolveFilename (module.js:325:15) 
    at Function.Module._load (module.js:276:25) 
    at Module.require (module.js:353:17) 
    at require (internal/module.js:12:17) 
    at Object.<anonymous> (/Users/path/to/gulpfile.js:16:21) 
    at Module._compile (module.js:409:26) 
    at Object.Module._extensions..js (module.js:416:10) 
    at Module.load (module.js:343:32) 
    at Function.Module._load (module.js:300:12) 
    at Module.require (module.js:353:17) 
    at require (internal/module.js:12:17) 

merge-streamという名前のいくつかの必要なモジュールがあります表示されますか?これは正しいです?もしそうなら、どこでどのようにこのモジュールを手に入れることができますか?または、これを引き起こしている他の問題がいくつかありますか?

I just copied the files package.json, polymer.json and gulpfile.js from the sample code Rob supplied here

gulpfile.js
'use strict'; 

// Documentation on what goes into PolymerProject. 
const path = require('path'); 
const gulp = require('gulp'); 
const mergeStream = require('merge-stream'); 
const del = require('del'); 
const polymerJsonPath = path.join(process.cwd(), 'polymer.json'); 
const polymerJSON = require(polymerJsonPath); 
const polymer = require('polymer-build'); 
const polymerProject = new polymer.PolymerProject(polymerJSON); 
const buildDirectory = 'build/bundled'; 

/** 
* Waits for the given ReadableStream 
*/ 
function waitFor(stream) { 
    return new Promise((resolve, reject) => { 
    stream.on('end', resolve); 
    stream.on('error', reject); 
    }); 
} 

function build() { 
    return new Promise((resolve, reject) => { 
    // Okay, so first thing we do is clear the build 
    console.log(`Deleting build/ directory...`); 
    del([buildDirectory]) 
     .then(_ => { 
     // Okay, now lets get your source files 
     let sourcesStream = polymerProject.sources() 
      // Oh, well do you want to minify stuff? Go for it! 
      // Here's how splitHtml & gulpif work 
      .pipe(polymerProject.splitHtml()) 
      .pipe(gulpif(/\.js$/, uglify())) 
      .pipe(gulpif(/\.css$/, cssSlam())) 
      .pipe(gulpif(/\.html$/, htmlMinifier())) 
      .pipe(polymerProject.rejoinHtml()); 

     // Okay now lets do the same to your dependencies 
     let depsStream = polymerProject.dependencies() 
      .pipe(polymerProject.splitHtml()) 
      .pipe(gulpif(/\.js$/, uglify())) 
      .pipe(gulpif(/\.css$/, cssSlam())) 
      .pipe(gulpif(/\.html$/, htmlMinifier())) 
      .pipe(polymerProject.rejoinHtml()); 

     // Okay, now lets merge them into a single build stream. 
     let buildStream = mergeStream(sourcesStream, depsStream) 
      .once('data',() => { 
      console.log('Analyzing build dependencies...'); 
      }); 

     // If you want bundling, do some bundling! Explain why? 
     buildStream = buildStream.pipe(polymerProject.bundler); 

     // If you want to add prefetch links, do it! Explain why? 
     // buildStream = buildStream.pipe(new PrefetchTransform(polymerProject)); 

     // Okay, time to pipe to the build directory 
     buildStream = buildStream.pipe(gulp.dest(buildDirectory)); 

     // waitFor the buildStream to complete 
     return waitFor(buildStream); 
     }) 
     .then(_ => { 
     // You did it! 
     console.log('Build complete!'); 
     resolve(); 
     }); 
    }); 
} 

gulp.task('default', build); 

答えて

1

merge-streamはすでにdevDependency in package.jsonとして宣言されているので、エラーは、依存関係をインストールしていない、またはそのパッケージが何らかの形であなたの依存関係ストア(すなわち、node_modules/)から削除されるかを示しています。

yarn add merge-stream 

をしかし、一般的に成功するためにビルドのすべての依存関係をインストールするために必要です:

npm install merge-stream 

かを:

だけ merge-streamをインストールするには、プロジェクトのルートディレクトリからこれを実行すると思います。代わりにこれを実行します。

npm install 

か:

yarn 
+0

'NPMのinstall'は+1を働きました – Mowzer

関連する問題