You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Error was reported after Electron APP was packed: Cannot find module 'reflect-metadata'.In package.json, the reflect-metadata exists! I don't know if it's a bug. I need help, thanks!
To Reproduce
First, running electron-serve can be used normally;
But, error was reported after electron app was packed: cannot find module 'reflect-metadata';
Expected behavior
The Electron App can be packed and run normally
Screenshots
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module 'reflect-metadata'
Require stack:
- /Applications/aDemo.app/Contents/Resources/app.asar/node_modules/@nestjs/core/index.js
- /Applications/aDemo.app/Contents/Resources/app.asar/background.js
-
at Module._resolveFilename (internal/modules/cjs/loader.js:887:15)
at Function.n._resolveFilename (electron/js2c/browser_init.js:257:1128)
at Module._load (internal/modules/cjs/loader.js:732:27)
at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
at Module.require (internal/modules/cjs/loader.js:959:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Applications/aDemo.app/Contents/Resources/app.asar/node_modules/@nestjs/core/index.js:11:1)
at Module._compile (internal/modules/cjs/loader.js:1078:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1108:10)
at Module.load (internal/modules/cjs/loader.js:935:32)
Environment (please complete the following information):
By looking at the official documentation, I found a solution.The official documentation is as follows:
Native modules are supported and should work without any configuration, assuming nodeIntegration is enabled. If you get errors, you may need to set the native dependency as an webpack external (opens new window). It should get found automatically, but it might not. To do this, use the externals option:
// vue.config.js
module.exports = {
pluginOptions: {
electronBuilder: {
// List native deps here if they don't work
externals: ['my-native-dep'],
// If you are using Yarn Workspaces, you may have multiple node_modules folders
// List them all here so that VCP Electron Builder can find them
nodeModulesPath: ['../../node_modules', './node_modules']
}
}
}
// vue.config.js
module.exports = {
pluginOptions: {
electronBuilder: {
// List native deps here if they don't work
externals: ['my-native-dep'],
// If you are using Yarn Workspaces, you may have multiple node_modules folders
// List them all here so that VCP Electron Builder can find them
nodeModulesPath: ['../../node_modules', './node_modules']
}
}
}
Wow!
Thank you so much man! I had been trying to find a solution for this error for days.
Describe the bug
Error was reported after Electron APP was packed: Cannot find module 'reflect-metadata'.In package.json, the reflect-metadata exists! I don't know if it's a bug. I need help, thanks!
To Reproduce
Expected behavior
The Electron App can be packed and run normally
Screenshots
Environment (please complete the following information):
vue info
:Additional context
none
The text was updated successfully, but these errors were encountered: