Whenever I run ionic build android I get following error
ngc error: Error: Error Cannot write file '.tmp/app/app.component.d.ts' because it would overwrite input file.
Error Cannot write file 'C:/GIT/TestProj/.tmp/domain/ListingModel.d.ts' because it would overwrite input file.
and a bunch of similar errors
Steps to reproduce:
1.
2.
3.
Which @ionic/app-scripts version are you using?
"@ionic/app-scripts": "latest",
Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)
[09:52:05] lint finished in 969 ms
[09:52:06] ngc: Error: Error Cannot write file 'C:/GIT/TestProj/.tmp/app/app.component.d.ts' because it would overwrite input file.
Error Cannot write file 'C:/GIT/TestProj/.tmp/domain/ListingModel.d.ts' because it would overwrite input file.
Error Cannot write file 'C:/GIT/TestProj/.tmp/pages/listing-details/listing-details.d.ts' because it would overwrite input file.
Error Cannot write file 'C:/GIT/TestProj/.tmp/pages/listings/listings.d.ts' because it would overwrite input file.
Error Cannot write file 'C:/GIT/TestProj/.tmp/pipes/boolFormatterPipe.d.ts' because it would overwrite input file.
Error Cannot write file 'C:/GIT/TestProj/.tmp/pipes/emptyString.d.ts' because it would overwrite input file.
Error Cannot write file 'C:/GIT/TestProj/.tmp/services/DataService.d.ts' because it would overwrite input file.
Error Cannot write file 'C:/GIT/TestProj/.tmp/services/SettingsService.d.ts' because it would overwrite input file.
at Object.check (C:\GIT\TestProj\TestProj.App\node_modules\@angular\tsc-wrapped\src\tsc.js:31:15)
at Object.main (C:\GIT\TestProj\TestProj.App\node_modules\@angular\tsc-wrapped\src\main.js:26:15)
at Object.<anonymous> (C:\GIT\TestProj\TestProj.App\node_modules\@angular\compiler-cli\src\main.js:14:9)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
[09:52:06] ngc: Compilation failed
[09:52:06] ngc failed: NGC encountered an error
[09:52:06] Error: NGC encountered an error
at ChildProcess.<anonymous> (C:\GIT\TestProj\TestProj.App\node_modules\@ionic\app-scripts\dist\ngc.js:62:24)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at ChildProcess.cp.emit (C:\GIT\TestProj\TestProj.App\node_modules\cross-spawn\lib\enoent.js:40:29)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
Error running ionic app script "build": Error: NGC encountered an error
npm
ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm
ERR! node v6.7.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world@ build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-hello-world@ build script 'ionic-app-scripts build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ionic-hello-world package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ionic-app-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ionic-hello-world
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ionic-hello-world
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\GIT\TestProj\TestProj.App\npm-debug.log
Caught exception:
undefined
@pantonis,
What happens if you delete the .tmp directory and try again? Run npm run build and see what the output is.
Thanks,
Dan
@danbucholtz
I deleted the .tmp folder still the problem exists. What I found out though is that in each page folder I had the following structure
|src/
|-page/
|---home/
|-----home.html
|-----home.scss
|-----home.ts
|-----home.d.ts
note the d.ts file.
Once I deleted this d.ts file and all other d.ts files from pages the problem went away.
I am using VS2015 community edition.
Why it produces these?
Ahhh, I think it because it is compiling code on save. We don't support that functionality and it should be disabled in the tsconfig.json file. Try disabling that or using VS Code to see if that resolves it.
Thanks,
Dan
@pantonis,
I'm going to close this issue, but please let me know how everything is going and if there's anything else we can help get squared away with visual studio.
Thanks,
Dan
I abandoned VS for VS code. everything works smoothly now.
Thanks
I have the same problem, I tried with two different projects and didn't work!!!
`sudo ionic build android
Password:
Running 'build:before' npm script before build
ionic-hello-world@ build /Users/aneudysamparo/[FOLDER]
ionic-app-scripts build
[01:09:30] ionic-app-scripts 0.0.36
[01:09:30] build prod started ...
[01:09:30] clean started ...
[01:09:30] clean finished in 1 ms
[01:09:30] copy started ...
[01:09:30] ngc started ...
[01:09:30] copy finished in 59 ms
[01:09:31] lint started ...
[01:09:33] lint finished in 2.17 s
[01:09:36] ngc finished in 6.03 s
[01:09:36] bundle started ...
[01:09:38] bundle failed: Could not resolve './app.module.ngfactory' from /Users/aneudysamparo/[FOLDER]/.tmp/app/main.prod.ts
[01:09:38] ionic-app-script task: "build"
[01:09:38] Error: Could not resolve './app.module.ngfactory' from /Users/aneudysamparo/[FOLDER]/.tmp/app/main.prod.ts
npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build" "--color"
npm ERR! node v6.4.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world@ build: ionic-app-scripts build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-hello-world@ build script 'ionic-app-scripts build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ionic-hello-world package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ionic-app-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ionic-hello-world
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ionic-hello-world
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /[FOLDER]/npm-debug.log
Caught exception:
undefined
Mind letting us know? https://github.com/driftyco/ionic-cli/issues
[FOLDER] aneudysamparo$ `
In tsconfig.json compileOnSave = False;
I'm using VS Code.
PS... I had Installed Node, Ionic, Cordova all them lastest version.
@aneudysamparo,
Can you paste your tsconfig.json in here? I think this issue is fixed in a release we have planned for today.
Thanks,
Dan
Hello @danbucholtz ,
Here my tsconfig.json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"target": "es5"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
@aneudysamparo, we are pushing out a fix for this shortly. In the meantime, you can remove include from the tsconfig, but we will want to add that back in in a few hours.
Thanks,
Dan
@danbucholtz , I also get the issue (and opened a StackOverflow ) my version is:
Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS: Windows 10
Node Version: v6.7.0
My tsconfig.json looks like that (no "include" and "compileOnSave:false"):
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"target": "es5"
},
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
Same problem here!
@RoyBkker, set declaration to false.
Thanks,
Dan
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5"
},
"include": [
"src/*/.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
what i have to change in this file
works for me:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"target": "es5"
},
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
Changing declaration to false as shown in abetsagaral's comment fixed it for me.
Go ahead and update your tsconfig.json to match this:
https://github.com/driftyco/ionic2-app-base/blob/master/tsconfig.json
Thanks,
Dan
I have same problem in Visual Studio 2015. And Fix by Installing:
npm install @ionic/app-scripts@latest --save-dev
Thanks @dalbir. I tried your suggestion using VS Code, the issue was resolved.
@dalbir Thanks problem resolve
@Omenjay i have the same problem here, im using sublime.. why is it using VS code could resolve this error instead of sublime?
@markiam11 I was using VS Code integrated terminal to run the npm command. I'm not too sure how sublime works for this similar functionality. You can look at the below post for other alternatives:
https://www.themarketingtechnologist.co/how-to-update-an-out-of-date-package-json/
Most helpful comment
I abandoned VS for VS code. everything works smoothly now.
Thanks