wojtkowiak / meteor-desktop

Build a Meteor's desktop client with hot code push.
MIT License
448 stars 81 forks source link

TypeError [ERR_INVALID_ARG_TYPE] #303

Open tiagohintz opened 2 years ago

tiagohintz commented 2 years ago

When starting the new project after installing and configuring meteor-desktop it displays the error (Note: This only happens in Meteor version 2.3 and above "Node 14", in versions with Node 12 and 10 the problem does not occur):

[meteor-desktop] calculated .desktop hash version is 8704ea9ec60f81720ae71a4fbc0216d38581a0aa_dev
internal/fs/utils.js:793                      
  throw new ERR_INVALID_ARG_TYPE(
  ^

TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at Object.writeFileSync (fs.js:1517:5)
    at Module.<anonymous> (/Users/tiagohintz/.meteor/packages/meteor-tool/.2.3.6.1s8cqvg.rum1k++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/tools/fs/tools/fs/files.ts:1641:23)
    at packages/meteor-desktop-bundler/bundler.js:869:48
    at runAsync (/Users/tiagohintz/node_modules/@babel/core/lib/transformation/index.js:40:10)
    at /Users/tiagohintz/node_modules/@babel/core/lib/transform.js:34:34
    at processTicksAndRejections (internal/process/task_queues.js:77:11) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Project details: meteor: 2.3.6 (Blaze) meteor-desktop: 2.2.5 electron: 6.1.7 electron-builder: 21.2.0 jquery: 3.5.1 OS: MacOS - Darwin 192.168.1.12 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64

Tanks

tiagohintz commented 2 years ago

Also tested with Meteor version 2.4 (Blaze) and the same error occurs.

AmitDigga commented 2 years ago

Any one solved it yet?

cfesas01 commented 2 years ago

Same issue

wildhart commented 2 years ago

I've tracked it down to this code in https://github.com/wojtkowiak/meteor-desktop/blob/01fb583d25b7b0f82308677389bce77cb5c8ce79/plugins/bundler/bundler.js#L869

image

In development mode, uglifiedCode will be undefined, which causes an error since fs.writeFileSync introduced type checking of the data parameter in Node 14.

My work-around is to copy the /plugins/bundler folder into my project's /packages folder (so that Meteor uses my local copy of the package), then change that line to uglifiedCode || code.

wildhart commented 2 years ago

Also, all these warnings are produced by meteor-desktop's dependency on shelljs@0.8.2. To remove these warnings this should be updated to >= 0.8.4 ref https://github.com/shelljs/shelljs/issues/991#issuecomment-619316520

(node:20512) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:20512) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:20512) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:20512) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:20512) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:20512) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:20512) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:20512) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
...
evan-coygo commented 2 years ago

I've included your fixes in a pull request to the Meteor-Community org's fork of this package since this is no longer maintained https://github.com/Meteor-Community-Packages/meteor-desktop/pull/7 . I'm hoping to get this published as meteor-desktop version 2.2.6