Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in vite compilation after importing log4js #1392

Open
Linjianwei99 opened this issue Sep 2, 2023 · 3 comments
Open

Error in vite compilation after importing log4js #1392

Linjianwei99 opened this issue Sep 2, 2023 · 3 comments

Comments

@Linjianwei99
Copy link

Linjianwei99 commented Sep 2, 2023

// logger.ts
import * as log4js from "log4js";

log4js.configure({
appenders: { cheese: { type: "file", filename: "cheese.log" } },
categories: { default: { appenders: ["cheese"], level: "error" } },
});

const logger = log4js.getLogger();

logger.level = "debug";
logger.debug("Some debug messages");

【tip】 After importing the logger.ts file into main.ts of Electron, an error was reported:
[vite]: Rollup failed to resolve import "@/electron/main/modules/logger.ts" from "E:/repository/electron-app/src/electron/main/index.ts".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external

【environment】
node: v18.16.0
electron: 25.2.0

@Linjianwei99
Copy link
Author

At present, I have resolved this error message. The reason for this error message is that vite cannot identify the dependencies or modules of this path. It is necessary to correctly configure the path when importing, such as using aliases or relative paths

@Linjianwei99
Copy link
Author

The specific reason is that the main. js electrical entry file in the project does not support the introduction of modules through aliasing

@GlodenBoy
Copy link

The specific reason is that the main. js electrical entry file in the project does not support the introduction of modules through aliasing

Hello, can you post a code example for the solution~ I am also experiencing this problem

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

No branches or pull requests

2 participants