Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

🚀 add patch for node v12.18.4 #105

Closed
wants to merge 1 commit into from
Closed

Conversation

n1ru4l
Copy link
Contributor

@n1ru4l n1ru4l commented Sep 18, 2020

No description provided.


const { SafeMap } = primordials;
-const { internalModuleReadJSON } = internalBinding('fs');
+const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
Copy link

@dio dio Sep 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but it seems like this gives:

pkg/prelude/bootstrap.js:1244
      throw error;
      ^

TypeError: internalModuleReadJSON is not a function or its return value is not iterable
    at Object.read (internal/modules/package_json_reader.js:17:34)
    at readPackage (internal/modules/cjs/loader.js:249:36)
    at readPackageScope (internal/modules/cjs/loader.js:287:19)
    at trySelf (internal/modules/cjs/loader.js:396:41)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:942:22)
    at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1338:44)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at Module.require (pkg/prelude/bootstrap.js:1225:31)
    at require (internal/modules/cjs/helpers.js:72:18)pkg/prelude/bootstrap.js:1244
      throw error;
      ^

TypeError: internalModuleReadJSON is not a function or its return value is not iterable
    at Object.read (internal/modules/package_json_reader.js:17:34)
    at readPackage (internal/modules/cjs/loader.js:249:36)
    at readPackageScope (internal/modules/cjs/loader.js:287:19)
    at trySelf (internal/modules/cjs/loader.js:396:41)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:942:22)
    at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1338:44)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at Module.require (pkg/prelude/bootstrap.js:1225:31)
    at require (internal/modules/cjs/helpers.js:72:18)

Copy link

@rahbari rahbari Sep 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rewriting this for node 14.12

internal/modules/package_json_reader.js:21
  const [string, containsKeys] = internalModuleReadJSON(
                                 ^

TypeError: internalModuleReadJSON is not a function or its return value is not iterable
    at Object.read (internal/modules/package_json_reader.js:21:34)
    at readPackage (internal/modules/cjs/loader.js:264:36)
    at readPackageScope (internal/modules/cjs/loader.js:297:19)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1087:17)
    at Module.load (internal/modules/cjs/loader.js:941:32)
    at Function.Module._load (internal/modules/cjs/loader.js:782:14)
    at Function.Module.runMain (pkg/prelude/bootstrap.js:1375:12)
    at internal/main/run_main_module.js:17:47

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you come up with a fix?

@rand256
Copy link

rand256 commented Sep 28, 2020

I've compiled it for armv7 and the resulting app can't start complaining that it can't parse the main package.json that is perfectly valid:

# ./myapp
internal/modules/cjs/loader.js:274
    throw e;
    ^

SyntaxError: Error parsing /snapshot/myapp/package.json: Unexpected end of JSON input
    at parse (<anonymous>)
    at readPackage (internal/modules/cjs/loader.js:262:20)
    at readPackageScope (internal/modules/cjs/loader.js:287:19)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1148:17)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.Module.runMain (pkg/prelude/bootstrap.js:1375:12)
    at internal/main/run_main_module.js:17:47 {
  path: '/snapshot/myapp/package.json'

It looks like the only opening brace character is read from the file somehow, so obviously the input's end is unexpected.

@alexk111
Copy link

alexk111 commented Jan 9, 2021

TypeError: internalModuleReadJSON is not a function or its return value is not iterable

In newer versions of Node.js the internalModuleReadJSON function returns an array instead of a string. To fix the mentioned issue pkg's bootstrap.js should also be updated. Here is the fixed one: alexk111/pkg@0a9eefb

@n1ru4l n1ru4l closed this Mar 5, 2021
@n1ru4l n1ru4l deleted the node12.8.4 branch March 5, 2021 20:48
@n1ru4l
Copy link
Contributor Author

n1ru4l commented Mar 5, 2021

If anyone wanna pick this up feel free. I am going to fully migrate over to caxa once it supports ARM leafac/caxa#4

@xanonid
Copy link
Contributor

xanonid commented Mar 5, 2021

I am working on a node v12.21.0 patch based on this PR.

@leerob
Copy link
Member

leerob commented Mar 5, 2021

Thank you @xanonid! 🙏

@david-mohr
Copy link
Contributor

I have a fix for the internalModuleReadJSON function in #118

--- node/lib/internal/modules/package_json_reader.js
+++ node/lib/internal/modules/package_json_reader.js
@@ -1,7 +1,7 @@
 'use strict';

 const { SafeMap } = primordials;
-const { internalModuleReadJSON } = internalBinding('fs');
+const internalModuleReadJSON = function (f) { let json = require('fs').internalModuleReadJSON(f); return [json, !!json]; };
 const { pathToFileURL } = require('url');
 const { toNamespacedPath } = require('path');

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants