Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView

Our build environment currently uses node 12.19.0 and npm 6.14.8. When I saw that the new LTS version of node 14.15.1 (still npm 6.14.8) was available I downloaded it and ran our webpack build script and received this error. Is the new version of node complaining about an error that was always there, but ignored by 12.19.0?

internal/fs/utils.js:781
  throw new ERR_INVALID_ARG_TYPE(
  ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of XMLElement
    at writeFile (fs.js:1436:5)
    at go$writeFile (/Components/node_modules/graceful-fs/graceful-fs.js:131:14)
    at Object.writeFile (/Components/node_modules/graceful-fs/graceful-fs.js:128:12)
    at /Components/node_modules/jest-html-reporter/dist/main.js:47:13
    at /Components/node_modules/mkdirp/index.js:48:26
    at callback (/Components/node_modules/graceful-fs/polyfills.js:295:20)
    at FSReqCallback.oncomplete (fs.js:184:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}
like image 233
cmulzer Avatar asked Dec 04 '20 04:12

cmulzer


People also ask

What are the requirements for the data argument of a buffer?

The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined #1323

What is error 1 TypeError [err_invalid_ARG_type]?

1 TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object 0 Project is not running in Angular

What are the requirements for the data argument in JavaScript?

0 The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined Hot Network Questions If I disagree with the research community, should I review papers against my beliefs or the community's?


2 Answers

Uplift jest-html-reporter version to at least 3.1.3

like image 173
Seb Avatar answered Nov 14 '22 18:11

Seb


Add a second argument to writeFileSync

Instead of:

fs.writeFileSync(`${folderName}/styles.css`);

Do this:-

fs.writeFileSync(`${folderName}/styles.css`, '');

It tells wfs what to write to the file. It can be left empty

like image 36
GuruTheCoder Avatar answered Nov 14 '22 18:11

GuruTheCoder