kyt icon indicating copy to clipboard operation
kyt copied to clipboard

fs.writeFile throws ERR_INVALID_CALLBACK

Open koebeen opened this issue 7 years ago • 8 comments

Versions of kyt, node, OS

kyt 0.9.0 node 10.6.0 OS macos 10.11.6

Bug or Feature?

Bug

Current Behavior

yarn dev or npm run dev results in an error

Desired Behavior

no error is thrown. app runs.

Fix:

line 72 of webpack.base.js shoud read: fs.writeFileSync(assetsFilePath, JSON.stringify(assets, null, ' '), 'utf8'); instead of: fs.writeFile(assetsFilePath, JSON.stringify(assets, null, ' '), 'utf8');

Full error:

fs.js:133
  throw new ERR_INVALID_CALLBACK();
  ^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
    at maybeCallback (fs.js:133:9)
    at Object.writeFile (fs.js:1132:14)
    at WebpackAssetsManifest.done (/kyt/node_modules/kyt/config/webpack.base.js:72:16)
    at WebpackAssetsManifest.emit (events.js:182:13)
    at Compiler.applyPlugins (/kyt/node_modules/tapable/lib/Tapable.js:61:14)
    at /kyt/node_modules/webpack/lib/Compiler.js:273:13
    at Compiler.emitRecords (/kyt/node_modules/webpack/lib/Compiler.js:369:37)
    at /kyt/node_modules/webpack/lib/Compiler.js:267:12
    at /kyt/node_modules/webpack/lib/Compiler.js:362:11
    at next (/kyt/node_modules/tapable/lib/Tapable.js:218:11)

koebeen avatar Jul 21 '18 14:07 koebeen

@koebeen I've been running into this, too. I had to ensure that I was running on Node 8 (which is the LTS right now). I hope this helps!

awayken avatar Oct 02 '18 02:10 awayken

Yep, using Node 8 resolved the same error for me as well.

stmathew7 avatar Oct 27 '18 18:10 stmathew7

thanks guys. yeah, obvious in the end. i should have run the lts..

koebeen avatar Oct 27 '18 18:10 koebeen

@koebeen @awayken Is this issue resolved? Could it be closed? Thanks.

fesebuv avatar Nov 29 '18 14:11 fesebuv

Yes, please close it

On Thu, Nov 29, 2018 at 8:41 AM Felipe Buenaño [email protected] wrote:

@koebeen https://github.com/koebeen @awayken https://github.com/awayken Is this issue resolved? Could it be closed? Thanks.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NYTimes/kyt/issues/566#issuecomment-442857447, or mute the thread https://github.com/notifications/unsubscribe-auth/AlOHozbJRAQFestCzbKJ9s9kX2YTlQ2Jks5uz_IOgaJpZM4VZo3U .

stmathew7 avatar Nov 29 '18 15:11 stmathew7

Is Node v8 required to use kyt? I'm getting invalid callback error when following getting started instructions verbatim. If this is the case, it seems that either updating kyt to work with Node 10 or mentioning in the ReadMe that Node 8 is required would be appropriate, as Node 10.x is listed as the current LTS version.

jackgray avatar Jan 31 '19 21:01 jackgray

Node v10 is now LTS, when can we expect a solution for this?

DataRogue avatar Apr 25 '19 20:04 DataRogue

What worked for me, was editing webpack-version-file-plugin > index

VersionFile.prototype.writeFile = function(templateContent){ var self = this; fileContent = ejs.render(templateContent, self.options); fs.writeFile(self.options.outputFile, fileContent, {flag: 'w'}, function() {}); }

Note after the flag options, I just added a blank callback function. Then the build continued unhindered. Hope this helps someone.

kierandesmond avatar May 22 '20 08:05 kierandesmond