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.

tsconfig.json error: Cannot write file 'src/service-worker.js' because it would overwrite input file

See original GitHub issue

Describe the bug Reading the docs about service worker I added an empty service-worker.js in my src dir.

I need it empty so vite sees it and produces the code to register it in the final bundle (I will fill in the file afterwards).

But now my (default) tsconfig.json is complaining with:

{
	"resource": "/c:/kit/tsconfig.json",
	"owner": "typescript",
	"severity": 8,
	"message": "Cannot write file 'c:/kit/src/service-worker.js' because it would overwrite input file.",
	"source": "ts",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 1,
	"endColumn": 2
}

Why?

Information about your SvelteKit Installation:

Diagnostics
  • The output of npx envinfo --system --npmPackages svelte,@sveltejs/kit,vite --binaries --browsers:

    System: OS: Windows 10 10.0.19042 Binaries: Node: 14.16.1 - C:\Program Files\nodejs\node.EXE npm: 7.9.0 - C:\Program Files\nodejs\npm.CMD npmPackages: @sveltejs/kit: 1.0.0-next.71 => 1.0.0-next.71 svelte: 3.37.0 => 3.37.0 vite: 2.1.5 => 2.1.5

  • Your adapter: static

Additional context Maybe related to https://github.com/sveltejs/kit/pull/716.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ZerdoX-xcommented, Nov 24, 2021

For me this is not related to service worker. I’ve inited svelte project and I don’t have it for now.

Reproducable like this: (choose yes to typesrcipt)

npm init svelte@next my-app
cd my-app
npm install
touch src/test.js
[{
	"resource": "/Users/zerdox/p/midas/frontend/tsconfig.json",
	"owner": "typescript",
	"severity": 8,
	"message": "Cannot write file '/Users/zerdox/p/midas/frontend/src/test.js' because it would overwrite input file.",
	"source": "ts",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 1,
	"endColumn": 2
}]

EDIT: Sorry guys for ping. This is svelte vscode extension issue. After restarting it everything works fine. In case I will get any problems I’ll open issue in svelte language tools repo

1reaction
chbertcommented, Apr 13, 2021

@ignatiusmb thanks for the reply! Restarting Svelte Language Server did the trick 👍 Sorry, was completely unaware of that, ~~in case somebody has the same issue: https://github.com/UnwrittenFun/svelte-vscode/blob/master/docs/preprocessors/typescript.md#:~:text=Restart the svelte language server&text=Hit ctrl-shift-p or,re now all set up!~~

Edit: see comment below

Read more comments on GitHub >

github_iconTop Results From Across the Web

visual studio - Typescript error "Cannot write file ... because it ...
js ' because it would overwrite input file. It looks like this all the time. It doesn't actually prevent building, and everything works...
Read more >
Cannot write file because it would overwrite input file TS
The error "Cannot write file because it would overwrite input file" occurs when we haven't specified the outDir directory in the exclude array...
Read more >
TypeScript: cannot write file .d.ts because it would overwrite ...
json or as part of the tsc arguments, and you're asking TypeScript to output type declarations in the same place. Then the error...
Read more >
Error “Cannot write file … because it would overwrite input file.”
In this post am going to share with you the irritating typescript warnings and how it was solved for me. Below is the...
Read more >
Configuration • Docs • SvelteKit
Your project's configuration lives in a svelte.config.js file at the root of your project. As well as SvelteKit, this config object is used...
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