-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
Module does not provide an export #282
Comments
@jjfufu , could you share more code (imports and exports)? |
The program is just a part of an application. I try to run only one module. (it work's under v8.1)
I can't provide the repository. The executed file
import {ConfigStore, setStoreObject} from '../../shared/utils/store.js'
import {stringToBoolean, stringToNumber} from '../../shared/utils/functions.js'
import {SupportedCollector} from '../../backend/modules/collector/collector.js'
import {BackendModule} from '../../backend/index.js'
import {isDev} from '../../shared/utils/env.js'
function getConfig(): ConfigStore {
return {...someData}
}
const config = getConfig()
const collectorOptions = config.collector
const database = config.database
setStoreObject(config)
const backend = new BackendModule({
collectorOptions: {...collectorOptions},
driverOptions: {
password: database.password,
user: database.user,
database: database.name,
host: database.host,
port: database.port
}
})
const collector = backend.getCollector()
if(!collector) {
throw new Error(`Collector is not defined. Unsupported collector name ${collectorOptions.name}`)
}
collector.setup() Store fileimport ElectronStore from 'electron-store'
const store = new ElectronStore<ConfigStore>({
encryptionKey: 'encryptionKey',
accessPropertiesByDotNotation: true,
})
export const setStoreObject = (object: Partial<ConfigStore>): void => {
return store.set(object)
} tsconfig.json{
"compilerOptions": {
"target": "esnext",
"module": "NodeNext",
"lib": ["esnext", "dom"],
"allowJs": true,
"outDir": "build",
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true,
"moduleResolution": "NodeNext",
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
"noUnusedLocals": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"inlineSources": true,
"sourceRoot": "/"
},
"include": [
"src/index.ts",
"src/setup/**/*.ts",
"src/backend/**/*.ts",
"src/backend/**/*.d.ts",
"src/electron/**/*.ts",
"src/electron/**/*.d.ts",
"src/shared/**/*.ts",
"src/shared/**/*.d.ts",
],
"exclude": ["node_modules", "src/frontend", "src/**/tests"]
} |
Which OS and version are you currently using? Electron has 3 different processes (preload, main & renderer) > which process context is this code being ran in? Are you currently running the tsx src/scripts/modules/backend.ts in the main thread? Make sure that the store is only initialized once (try to make use of the singleton pattern) and in a context where it can be created (my recommendation is to create this in the main processs) and use IPC connection at the renderer level if you need to send updates to the store. I also recommend separating the Then your {
"files": [],
"references": [{ "path": "./tsconfig.node.json" }, { "path": "./tsconfig.web.json" }]
} Here's how it can look: tsconfig.node.json {
"extends": "@electron-toolkit/tsconfig/tsconfig.node.json",
"include": [
"electron.vite.config.*",
"src/main/**/*",
"src/preload/**/*",
"src/main/*",
"src/main/**"
],
"compilerOptions": {
"composite": true,
"target": "ESNext",
"moduleResolution": "NodeNext",
"types": ["electron-vite/node"],
"baseUrl": ".",
"paths": {
"@electron-toolkit/*": ["node_modules/@electron-toolkit/*"]
}
},
"exclude": ["node_modules"]
} And the `tsconfig.web.json': {
"extends": "@electron-toolkit/tsconfig/tsconfig.web.json",
"include": [
"src/renderer/src/env.d.ts",
"src/renderer/src/**/*",
"src/renderer/src/**/*.tsx",
"src/preload/*.d.ts",
"src/renderer/src/**/*.ts",
"src/renderer/src/**/*.tsx"
],
"compilerOptions": {
"composite": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "preserve",
"jsxImportSource": "solid-js",
"allowJs": true,
"noEmit": true,
"strict": true,
"types": ["vinxi/types/client"],
"baseUrl": ".",
"paths": {
"@renderer/*": ["src/renderer/src/*"]
}
}
} |
Heya, I'm having the same issue and I'm using the Apart from what I've written in that thread, I've also tried calling import Store from 'electron-store';
const store = new Store(); Then I'm getting the following error: P.S.: I'm running on
|
I don't know why, but when i run my project i have this error.
Versions :
"electron": "32.0.1"
"electron-store": "^10.0.0"
The text was updated successfully, but these errors were encountered: