所以我的项目结构是我的根目录中有一个src和www目录./,它还包含我的bower.json,gulpfile.js和.bowerrc,目录设置为./www/bower/.
我的./src中有一个index.html,我已经设置了一个gulp任务,通过线程管理它,并出现在.
不幸的是,它添加了所有的依赖项,就像它在./src目录中一样,所以它们都是前缀,如../www/bower/,它的作用是最终的index.html最终在www目录中,所以我发现了一些如下所示的线路配置选项:
gulp.task('bower',function () { gulp.src('./src/index.html') .pipe(wiredep({ cwd: './www',bowerJson: require('./bower.json'),directory: '../.bowerrc' })) .pipe(gulp.dest('./www')); });
但是我收到以下错误:
stream.js:94 throw er; // Unhandled stream error in pipe. ^ TypeError: Cannot read property 'main' of undefined at findMainFiles (D:\DropBox\University\MindFlipDOM\node_modules\wiredep\lib\detect-dependencies.js:53:37) at D:\DropBox\University\MindFlipDOM\node_modules\wiredep\lib\detect-dependencies.js:111:17 at forOwn (D:\DropBox\University\MindFlipDOM\node_modules\wiredep\node_modules\lodash\dist\lodash.js:1301:15) at Function.forEach (D:\DropBox\University\MindFlipDOM\node_modules\wiredep\node_modules\lodash\dist\lodash.js:2595:9) at detect (D:\DropBox\University\MindFlipDOM\node_modules\wiredep\lib\detect-dependencies.js:312:5) at wiredep (D:\DropBox\University\MindFlipDOM\node_modules\wiredep\wiredep.js:178:39) at Transform._transform (D:\DropBox\University\MindFlipDOM\node_modules\wiredep\wiredep.js:217:34) at Transform._read (D:\DropBox\University\MindFlipDOM\node_modules\wiredep\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:184:10) at Transform._write (D:\DropBox\University\MindFlipDOM\node_modules\wiredep\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:172:12) at doWrite (D:\DropBox\University\MindFlipDOM\node_modules\wiredep\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:238:10)
那我做错了什么?
解决方法
还要尝试,这将确保下载缺少的必要模块.
bower install