[英]File 'main.ts' not found
What is the correct solution for this error?这个错误的正确解决方案是什么?
PS C:\Users\****\Like-Component> tsc main.ts
error TS6053: File 'main.ts' not found.
The file is in the program because:
Root file specified for compilation
Found 1 error.
The solution to this error is already explained in the error message.错误消息中已经说明了此错误的解决方案。 Basically when you add
rootDir
address already in tsconfig.json
file.基本上,当您在
tsconfig.json
文件中添加rootDir
地址时。 Your tsc
command will follow it and start looking for .ts
files in the folder inside the address you mentioned in rootDir
.您的
tsc
命令将跟随它并开始在您在rootDir
中提到的地址内的文件夹中查找.ts
文件。
just run
tsc
instead oftsc main.ts
只需运行
tsc
而不是tsc main.ts
your tsc
will automatically go inside the rootDir
and look for available ts files.您的
tsc
将自动 go 在rootDir
并查找可用的 ts 文件。 Simple!简单的!
Here is my tsconfig.json
file这是我的
tsconfig.json
文件
{
"compilerOptions": {
"target": "es6",
"module": "CommonJS",
"outDir": "./public",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src"]
}
Go to src folder Go 到 src 文件夹
Create a new file named main.ts创建一个名为main.ts的新文件
Paste following code in the file.将以下代码粘贴到文件中。
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
Save the file保存文件
Restart project This will work now重新启动项目这现在可以工作了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.