question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The "data" argument must be one of type string, TypedArray, or DataView. Received type object

See original GitHub issue

🐛 bug report

Watching .sass files resulted in a weird exception. It only happened once and I’m not able to reproduce it.

🎛 Configuration (.babelrc, package.json, cli command)

No configuration.

🤔 Expected Behavior

The .sass files should be compiled normally.

😯 Current Behavior

The compilation fails with the following error:

> parcel watch resources/sass/*.sass --no-source-maps -d public/assets/css --no-hmr

🚨  The "data" argument must be one of type string, TypedArray, or DataView. Received type object
    at Hash.update (internal/crypto/hash.js:58:11)
    at Bundle.getHash (/mnt/Portable/Projekte/treb/node_modules/parcel-bundler/src/Bundle.js:301:12)
    at Bundle.package (/mnt/Portable/Projekte/treb/node_modules/parcel-bundler/src/Bundle.js:186:23)
    at Bundler.bundle (/mnt/Portable/Projekte/treb/node_modules/parcel-bundler/src/Bundler.js:325:56)
    at process._tickCallback (internal/process/next_tick.js:68:7)

💁 Possible Solution

???

🔦 Context

I need the .sass files compiled to CSS.

💻 Code Sample

Nothing wrong with my .sass files.

🌍 Your Environment

Software Version(s)
Parcel 1.12.3
Node 10.16.3
npm/Yarn 6.12.0
Operating System Ubuntu x64 5.0.0-31-generic #33~18.04.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:13

github_iconTop GitHub Comments

14reactions
jordanjtidwellcommented, Dec 14, 2019

This may or may not help anyone else (doesn’t fix parcel itself either), but I also got this error and it turned out I had a script tag pointing to a non-existent file. Fixing that resolved this issue for me. 👍

5reactions
afeinmancommented, Oct 24, 2019

Hit this bug as well. It only happens on refresh when there is a malformed target.

I added some exception-handling code to Bundle.js, and discovered that it was because of malformed HTML in a watched file, specifically:

<body>
  <script src="scriptCannotBeUnitaryTag" />
</body>

I modified Bundle.js to add some error handling:

  getHash() {
    let hash = crypto.createHash('md5');
    for (let asset of this.assets) {
      try {
        hash.update(asset.hash);
      } catch (Ex) { // Added this clause
        console.error("Couldn't import: ", asset.name, "\n\nBecause:", Ex);
      }
    }
    return hash.digest('hex');
  }

Which gave me this output (path elided):

$ parcel -p 5050 index.html
Server running at http://localhost:5050 
⠋ Building...Couldn't import:  [...]/index.html 

Because: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be one of type string, Buffer, TypedArray, or DataView. Received type object
    at Hash.update (internal/crypto/hash.js:70:11)
    at Bundle.getHash ([...]/node_modules/parcel/src/Bundle.js:302:12)
    at Bundle.package ([...]/node_modules/parcel/src/Bundle.js:186:23)
    at Bundler.bundle ([...]/node_modules/parcel/src/Bundler.js:325:49)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Timeout._onTimeout ([...]/node_modules/parcel/src/Bundler.js:817:7) {
  code: 'ERR_INVALID_ARG_TYPE'
}
✨  Built in 15ms.

Hopefully this is enough detail for someone to fix this! I’d love to get the root error message (“index.html:1:1: Unexpected token (1:1)”) instead of the weird TypeError message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - NodeJS: Data argument must be of type string/Buffer ...
So the error is saying the data (second argument of the fs.writeFileSync function) should be a string or a buffer...etc but instead got...
Read more >
typeerror: the "data" argument must be of type string or an ...
So the error is saying the data (second argument of the fs.writeFileSync function) should be a string or a buffer...etc but instead got...
Read more >
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument ...
AssertionError: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an ...
Read more >
Help needed: The "data" argument must be of type string or an ...
Received an instance of Node - Ember.JS ...
Read more >
The "data" argument must be of type string or an instance of ...
**TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found