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.
This commit is contained in:
Jack Teng 2018-06-18 16:09:11 -07:00
parent 295c823a1b
commit 10df019075

View file

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