So my project structures is I have a src
and www
directory in my root ./
, which also contains my bower.json
, gulpfile.js
, and .bowerrc
with the directory
set to ./www/bower/
.
I have an index.html
in my ./src
and I've setup a gulp task that pipes it through wiredep
and out to the ./www
where the bower packages are.
Unfortunately it adds all the dependecies as if it's in the ./src
directory so all of them are prefixed like ../www/bower/
which does work as the final index.html
ends up in the www
directory so I fiddled with some of the wiredep
configuration options like so:
gulp.task('bower', function () {
gulp.src('./src/index.html')
.pipe(wiredep({
cwd: './www',
bowerJson: require('./bower.json'),
directory: '../.bowerrc'
}))
.pipe(gulp.dest('./www'));
});
However I get the following error:
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)
So what am I doing wrong?
To solve the "Cannot read properties of undefined" error, make sure that the DOM element you are accessing exists. The error is often thrown when trying to access a property at a non-existent index after using the getElementsByClassName() method. Copied! const boxes = document.
The "Cannot read property 'toString' of null" error occurs when the toString() method is called on a null value. To solve the error, make sure to only call the toString method on data types that implement the method.
The "Cannot read property 'split' of undefined" error occurs when trying to call the split() method on a variable that stores an undefined value. To solve the error, make sure to only call the split() method on strings.
The "Cannot read property 'click' of null" error occurs when trying to call the click method on a null value. To solve the error, run the JS script after the DOM elements are available and make sure you only call the method on valid DOM elements.
Also try, this will make sure to download the necessary modules that were missing.
bower install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With