I'm trying to update an existing angular website from angular version 5 to version 6. After I updated the values in package.json and migrated the .angular-cli.json to the new angular.json format, I tried to run my application and it crashes with this cryptic error:
TypeError: pna.nextTick is not a function
at maybeReadMore (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:517:9)
at addChunk (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:300:3)
at readableAddChunk (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:278:11)
at DestroyableTransform.Readable.push (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:245:10)
at DestroyableTransform.Transform.push (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_transform.js:148:32)
at DestroyableTransform.afterTransform (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_transform.js:91:10)
at DestroyableTransform.noop [as _transform] (/my_hd/node_modules/npm/node_modules/mississippi/node_modules/through2/through2.js:26:3)
at DestroyableTransform.Transform._read (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_transform.js:172:83)
at doWrite (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at DestroyableTransform.Writable.write (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:334:11)
at cacheStream.write (/my_hd/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/cache.js:183:17)
at afterWrite (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:491:3)
at onwrite (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:483:7)
at WritableState.onwrite (/my_hd/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:180:5)
When I go and look in the _stream_readable javascript file, here is the source code for the maybeReadMore method and the addChunk method:
// at this point, the user has presumably seen the 'readable' event,
// and called read() to consume some data. that may have triggered
// in turn another _read(n) call, in which case reading = true if
// it's in progress.
// However, if we're not ended, or reading, and the length < hwm,
// then go ahead and try to read some more preemptively.
function maybeReadMore(stream, state) {
if (!state.readingMore) {
state.readingMore = true;
pna.nextTick(maybeReadMore_, stream, state); // this is line 517 that crashes
}
}
// this is the addChunk method which calls maybeReadMore
function addChunk(stream, state, chunk, addToFront) {
if (state.flowing && state.length === 0 && !state.sync) {
stream.emit('data', chunk);
stream.read(0);
} else {
// update the buffer info.
state.length += state.objectMode ? 1 : chunk.length;
if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
if (state.needReadable) emitReadable(stream);
}
maybeReadMore(stream, state); // this is line 300 which calls maybeReadMore
}
I will note that I did not write this readable_stream library. It seems to have come with one of my angular dependencies. I did google on this problem and found that there is a 'readable-stream' dependency which can be added to package.json. When I first started experiencing this error, I tried manually adding the following line to package.json:
"readable-stream": "2.3.6",
However, the error message stayed unchanged. My original package.json file did not have readable-stream listed.
Does anyone have any idea of which dependency might be causing this problem or how to fix it?
Thanks.