I'm getting this error:
Import declaration conflicts with local declaration of 'fs'
in main
:
import fs from 'fs-extra'
fs.ensureDir(settingsUserDataFolder, err => {
console.log(err)
})
If I comment this part:
//fs.ensureDir(settingsUserDataFolder, err => {
//console.log(err)
//})
the error disappears
In webpack.main.config.js
:
const fs = require('fs-extra')
module.exports = {
// https://webpack.js.org/configuration/externals/#externalstypecommonjs
externalsType: 'commonjs',
externals: {
'fs': 'fs-extra',
}
};
ts.config.json
:
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 16",
"compilerOptions": {
"allowJs": true,
"lib": ["es2021", "dom", "dom.iterable"], // https://www.e-learn.cn/topic/3468143
"module": "commonjs",
"target": "es2019",
"skipLibCheck": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"jsx": "react",
"noImplicitAny": false,
"sourceMap": true,
"baseUrl": "./src",
"outDir": "dist",
"moduleResolution": "node",
"resolveJsonModule": true,
"paths": {
"@app/*": ["app/*"],
"*": ["node_modules/*"]
}
},
"include": ["./src/**/*"]
}
Other Info:
"typescript": "^4.9.3",
"electron": "^17.2.0",
"@electron-forge/plugin-webpack": "6.0.0-beta.63",
"@types/fs-extra": "^9.0.13",
"fs-extra": "^11.1.0",
node: v18.12.1
O.S.: Ubuntu 22.04 Desktop
With import fsExtra from 'fs-extra'
I get the same error:
Import declaration conflicts with local declaration of 'fsExtra'
How to solve the issue?