failed to import module in background.ts
See original GitHub issuevue-cli-plugin-electron-builder: 1.4.1 electron-builder: 21.2.0 typescript:3.5.3
Describe the bug error:
ERROR Failed to compile with 1 errors 6:47:38 PM This dependency was not found: * @/components/Workbench/B in ./src/components/Workbench/A.ts To install it, you can run: npm install --save @/components/Workbench/B
dependency chain:
background.ts
depends A.ts
,
A.ts
depends B.ts
src/background.ts
file content:
...
import a from './components/Workbench/A';
logger.debug(a.toString());
...
src/components/Workbench/A.ts
file content:
import b from '@/components/Workbench/B';
const a = 0;
export default b;
src/components/Workbench/B.ts
file content:
const b = 0;
export default b;
but if i change A.ts
’s contents to the following, it works :
import b from './B';
const a = 0;
export default b;
tsconfig.json contents:
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env",
"jest"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx",
"preloads/**/*.ts",
"preloads/**/*.tsx",
],
"exclude": [
"node_modules"
]
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
TypeScript ES6 import module "File is not a module error"
When I am trying to compile the main.ts file I get this error: Error TS2306: File 'test.ts' is not a module. How can...
Read more >Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >Dynamic module import doesn't work in webextension content ...
This is a BLOCKER for deloyment of module-based javascript content scripts. Since it works fine in background scripts (using <script type=module> in background....
Read more >Import-Module (Microsoft.PowerShell.Core)
This cmdlet imports only a version of the module that is less than or equal to the specified value. If no version qualifies,...
Read more >Common TypeScript module problems and how to solve them
ts . This time, the file does not exist, so the compiler will substitute 'nav/file3' with the second location " ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
OK I have found the solution:
See the docs: https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/configuration.html#webpack-configuration
As of v1.4.2
@
is aliased tosrc
. If you upgrade to that version it should work. https://github.com/nklayman/vue-cli-plugin-electron-builder/blob/master/index.js#L587