Browse Source

fix: can't load module error when app is packaged

due to change in node.js(https://github.com/nodejs/node/issues/17076)
internalModuleReadFile has been renamed to internalModuleReadJSON, and
in vendor/node/lib/internal/modules/cjs/loader.js it will call
internalModuleReadJSON and result in can't read the package.json file.
Jack Teng 6 years ago
parent
commit
10df019075
1 changed files with 3 additions and 3 deletions
  1. 3 3
      lib/common/asar.js

+ 3 - 3
lib/common/asar.js

@@ -590,11 +590,11 @@
       return files
     }
 
-    const {internalModuleReadFile} = process.binding('fs')
-    process.binding('fs').internalModuleReadFile = function (p) {
+    const {internalModuleReadJSON} = process.binding('fs')
+    process.binding('fs').internalModuleReadJSON = function (p) {
       const [isAsar, asarPath, filePath] = splitPath(p)
       if (!isAsar) {
-        return internalModuleReadFile(p)
+        return internalModuleReadJSON(p)
       }
       const archive = getOrCreateArchive(asarPath)
       if (!archive) {