"npm install -G typescript" fails with "npm ERR! The value "false" is invalid for option "readableHighWaterMark"

What I Wanted to Do

Trying to install typescript with npm directly into a new computer set up with VsCode which does not yet have typescript.

“npm install -G typescript”
but get error message that I cannot change
"npm ERR! The value “false” is invalid for option “readableHighWaterMark”

edit:
see later reply for dirty workaround and suggest that node look at the correcting the issue of cache management for larger downloads.

What Happened Instead

Reproduction Steps

<I have tried “npm install typescript” and get same error as the npm -G command
I am working on a new computer with Vscode, and recreating packages that require typescript also give the same error when using npm install when they get to a typescript dependency.
I cannot find much on the web for readable readableHighWatermark, and have not found any environment setting to define its value and correct this error.

Have also tried creating an brand new react typescript project yet still get the same error when it gets to typescript install:
create-react-app myreactAppts --typescript
Creating a new React app in D:\Ross_D_data\Programming-Angular\myreactappts.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts…

npm ERR! code ERR_INVALID_OPT_VALUE
npm ERR! The value “false” is invalid for option “readableHighWaterMark”

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\rossh\AppData\Roaming\npm-cache_logs\2019-07-07T01_15_35_190Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts @types/node @types/react @types/react-dom @types/jest typescript has failed.

Final try using older version of typescript install -G typescript@2.9 also fails with same error, suggesting it is not a latest version issue but probably an environment issue - still cannot find an appropriate option in npm config to reset. Can others help identify?
–>

Details

< View of of terminal command and output
D:\Ross_D_data\Programming-Angular\1_lrjh_react-direct-graph-master\src> npm install -G typescript
npm ERR! code ERR_INVALID_OPT_VALUE
npm ERR! The value “false” is invalid for option “readableHighWaterMark”

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\rossh\AppData\Roaming\npm-cache_logs\2019-07-07T00_27_19_832Z-debug.log–>

Platform Info

$ npm --versions
<{ 'react-direct-graph': '1.2.1',
  npm: '6.9.0',
  ares: '1.15.0',
  brotli: '1.0.7',
  cldr: '35.1',
  http_parser: '2.8.0',
  icu: '64.2',
  modules: '64',
  napi: '4',
  nghttp2: '1.34.0',
  node: '10.16.0',
  openssl: '1.1.1b',
  tz: '2019a',
  unicode: '12.1',
  uv: '1.28.0',
  v8: '6.8.275.32-node.52',
  zlib: '1.2.11' } -->
$ node -p process.platform
<!-- win32 -->

What is version of NodeJS you are using?

I was using node 10.16.0 LTS at the time of error.
I have since uninstalled node then reinstalled 12.6.0 Current version, but still get the same error.

Likewise I tried installing npm install of each older typescript package all the way back to typescript@2.9 and yet I get the same error on each.

This is why I think there is an environment setting yet to find on this new PC, as thousand of users are successfully installing typescript, including me on my last PC.

I have found the error lies inside the node modules - both 10.16.0 and 12.6.0 and found a dirty on-site workaround

The error is because the cache memory size is not working on large files and typescript is a 7.6MB download which is larger than the 5 MB cache default cache size that node uses.

To fix on site, I edited one of node modules mentioned in the cache to larger MAX_MEM_SIZE which allows it to work. Still it is a dirty fix, so there is still a bug to be fixed by node js.

My dirty fix was to edit inside
nodejs\node_modules\npm\make-fetch-happen\cache.js - line 12

change
const MAX_MEM_SIZE = 5 * 1024 * 1024 // 5MB to become
const MAX_MEM_SIZE = 25 * 1024 * 1024 // 25MB my temp fix to allow large downloads

Now npm install typescript will work!!!

2 Likes

This works, at least for now. Thanks.

Same thing, see https://github.com/nodejs/node/issues/29364

Unsure of the fix. Hit this in ubuntu on multiple node 12.x versions .