question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

failed to import module in background.ts

See original GitHub issue

vue-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:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
nklaymancommented, Dec 7, 2019

As of v1.4.2 @ is aliased to src. If you upgrade to that version it should work. https://github.com/nklayman/vue-cli-plugin-electron-builder/blob/master/index.js#L587

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found