Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_INVALID_ARG_TYPE when running less task #105

Closed
landlockedsurfer opened this issue Aug 6, 2020 · 3 comments
Closed

ERR_INVALID_ARG_TYPE when running less task #105

landlockedsurfer opened this issue Aug 6, 2020 · 3 comments

Comments

@landlockedsurfer
Copy link

Hi!
I ran into an issue with sbt-less resulting in the following build error

[info] LESS compiling on 1 source(s)
[error] internal/fs/utils.js:701
[error]     throw new ERR_INVALID_ARG_TYPE(
[error]     ^
[error] 
[error] TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
[error]     at Object.writeFile (fs.js:1385:5)
[error]     at /Users/landlockedsurfer/src/trash/sbt-less-example/project/target/less/lessc.js:89:20
[error]     at /Users/landlockedsurfer/src/trash/sbt-less-example/project/target/node-modules/webjars/mkdirp/index.js:47:26
[error]     at FSReqCallback.oncomplete (fs.js:177:5) {
[error]   code: 'ERR_INVALID_ARG_TYPE'
[error] }
...

The build error popped up yesterday all of a sudden (most likely due to a refresh of a node dependency).
After creating a standalone project I noticed that that issue seems to be related to files that are starting with the definition of a less variable.
I could not track down the cause of the problem but found a workaround by adding some additional lines at the top of the file.
E.g.
This file causes a build error

// /* add multiline comment to make things work, i.e. remove double slash at the start of this line */
// The problem seems to occur whenever the file starts with a variable declaration
@white: #fff;

By enabling the multiline comment at the start the less task runs fine again.

/* add multiline comment to make things work, i.e. remove double slash at the start of this line */
// The problem seems to occur whenever the file starts with a variable declaration
@white: #fff;

I've created a sample project to demonstrate the issue here: https://github.com/landlockedsurfer/sbt-less-test

Posting this workaround here in case someone else stumbles across this issue since I could not find anything in the internets.

@sbmpost
Copy link

sbmpost commented Aug 12, 2020

might be related to newer version of node

@TheNorthMemory
Copy link

TheNorthMemory commented Oct 28, 2020

I've also got the similar error messages whose came from lessc.js:89:20.

mkdirp(path.dirname(sourceMapOutput), function (e) {
throwIfErr(e);
fs.writeFile(sourceMapOutput, content, "utf8", onDone);
});

Checking the fs.writeFile((file, data[, options], callback)) manual, it was changed the behavior since v14.0.0 with:

The data parameter won't coerce unsupported input to strings anymore.

In L69, about the content, there was checked but L89 didn't. It should be undefined while less.sourceMap was turned as false or real empty(won't need). And then caused the fs.writeFile failed.

@mkurz
Copy link
Member

mkurz commented Jan 13, 2024

Fixed by

@mkurz mkurz closed this as completed Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants