-
Notifications
You must be signed in to change notification settings - Fork 776
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
Cannot find module log4js with TypeScript #1360
Comments
It seems that You can download this: npm i npx ts-node test.ts # works npx tsc test.ts # fails Switching to |
I have included your npm i
npx tsc Sorry, I'm not so familiar with TypeScript. But I don't have any errors. EDITED: This is because the |
It seems that these two configuration options cause the error. |
After removing the comments in You will need to add es2015 {
"compilerOptions": {
"target": "es2015",
"module": "es2015",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
+ "moduleResolution": "node",
"strict": true,
"skipLibCheck": true
}
} es2020 {
"compilerOptions": {
"target": "es2020",
"module": "es2020",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
+ "moduleResolution": "node",
"strict": true,
"skipLibCheck": true
}
} |
My problem has been solved. Thank you very much |
Use the import method to import log4js, execute the tsc command, and the error "Cannot find module 'log4js'" will be reported, but the compiled js file can run normally.
error TS2792: Cannot find module 'log4js'
index.ts:
`import 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");`
The text was updated successfully, but these errors were encountered: