问题
My NativeScript Angular project, on which I've been working for some time, stopped compiling about one week ago, error message is Build failed with error code 2
.
But, on another machine project compiles normally!
On both computers I use
NativeScript Sidekick, latest version: 1.19.1-v2019.8.1.2,
NativeScript CLI version: 6.0.3,
CLI extension nativescript-cloud version: 1.18.1,
CLI extension nativescript-starter-kits version: 0.3.5
I've reinstalled node, tns and Sidekick, I've deleted cloud cache, I've created new Telerik account in order to try to avoid anything cached on the cloud.
[19-08-19 10:18:56.133] Error detected during LiveSync on 709dacd534f7bbb357482d696468f8efbd5888ac for C:\Users\USR\Documents\NATIVESCRIPT\proj. Error: Build failed. Reason is: 'Build failed with error code 2'. Additional information: [00:00:27.138] [WARN] Executing webpack failed with exit code 2.
[00:00:27.522] [ERROR] Executing webpack failed with exit code 2.
'Build failed with error code 2'.
[19-08-19 10:20:26.189] Error detected during LiveSync on D67LLNGU7HY96HVO for C:\Users\USR\Documents\NATIVESCRIPT\proj. Error: Build failed. Reason is: 'Build failed with error code 2'. Additional information: [00:00:17.670] [WARN] Executing webpack failed with exit code 2.
[00:00:17.730] [ERROR] Module not found: Error: Can't resolve './info.component.css' in '/mnt/storage/builds/_/0065576d41c5e3acbcdc3ba31c41167f50faec72/6.0.3/6.0.0/proj/src/app/info'
[00:00:17.730] [ERROR] Module not found: Error: Can't resolve './specs1.component.css' in '/mnt/storage/builds/_/0065576d41c5e3acbcdc3ba31c41167f50faec72/6.0.3/6.0.0/proj/src/app/specs/specs1'
[00:00:17.731] [ERROR] Module not found: Error: Can't resolve './specs2.component.css' in '/mnt/storage/builds/_/0065576d41c5e3acbcdc3ba31c41167f50faec72/6.0.3/6.0.0/proj/src/app/specs/specs2'
[00:00:17.731] [ERROR] Module not found: Error: Can't resolve './lzs.component.css' in '/mnt/storage/builds/_/0065576d41c5e3acbcdc3ba31c41167f50faec72/6.0.3/6.0.0/proj/src/app/info/lzs'
[00:00:17.731] [ERROR] Module not found: Error: Can't resolve './specs.component.css' in '/mnt/storage/builds/_/0065576d41c5e3acbcdc3ba31c41167f50faec72/6.0.3/6.0.0/proj/src/app/specs'
[00:00:17.731] [ERROR] Module not found: Error: Can't resolve './aboutus.component.css' in '/mnt/storage/builds/_/0065576d41c5e3acbcdc3ba31c41167f50faec72/6.0.3/6.0.0/proj/src/app/aboutus'
[00:00:17.731] [ERROR] Module not found: Error: Can't resolve './pdk.component.css' in '/mnt/storage/builds/_/0065576d41c5e3acbcdc3ba31c41167f50faec72/6.0.3/6.0.0/proj/src/app/info/pdk'
[00:00:17.731] [ERROR] Module not found: Error: Can't resolve './tips1.component.css' in '/mnt/storage/builds/_/0065576d41c5e3acbcdc3ba31c41167f50faec72/6.0.3/6.0.0/proj/src/app/tips/tips1'
[00:00:17.731] [ERROR] Module not found: Error: Can't resolve './tips2.component.css' in '/mnt/storage/builds/_/0065576d41c5e3acbcdc3ba31c41167f50faec72/6.0.3/6.0.0/proj/src/app/tips/tips2'
[00:00:17.734] [ERROR] Module not found: Error: Can't resolve './stuff.component.css' in '/mnt/storage/builds/_/0065576d41c5e3acbcdc3ba31c41167f50faec72/6.0.3/6.0.0/proj/src/app/info/stuff'
[00:00:17.996] [ERROR] Executing webpack failed with exit code 2.
'Build failed with error code 2'.
I build simultaneously for iOS and Android.
EDIT:
[19-08-21 08:56:25.214] Build started.
[19-08-21 08:56:26.279] (CLI) Preparing project...
[19-08-21 08:56:26.286] (CLI) Project successfully prepared (ios)
[19-08-21 08:56:26.835] (CLI) Starting Cloud build. Cloud operation id: 8367422f-bdae-4aef-bb0c-a4ff5dcb94a8
[19-08-21 08:56:26.840] (CLI) Getting accounts information...
[19-08-21 08:56:27.785] (CLI) Using account 79475b26e9fe4bf1952e3298ce5c9214.
[19-08-21 08:56:27.785] (CLI) Cloud build of 'C:\Users\usr\Documents\ns\acmeapp', platform: 'iOS', configuration: 'Debug'.
[19-08-21 08:56:28.784] Upload step started.
[19-08-21 08:56:29.383] (CLI) Unable to use git, reason is:
[19-08-21 08:56:29.383] (CLI) Git Installation Not Found. Install Git to improve the speed of cloud builds.
[19-08-21 08:56:37.691] Upload step completed.
[19-08-21 08:56:39.237] Build step started.
[19-08-21 08:56:44.398] (CLI) ios Build Tooling revision 2019.08.07.1r
[19-08-21 08:56:44.398] (CLI) Build Tooling Hostname administrators-mac-14.local
[19-08-21 08:56:44.398] (CLI) Unzip Project Files
[19-08-21 08:56:44.398] (CLI) NativeScript CLI version 6.0.3
[19-08-21 08:56:44.398] (CLI) Add platform ios with runtime version 6.0.1
[19-08-21 08:56:47.360] (CLI) Copying template files...
[19-08-21 08:56:50.375] (CLI) Platform ios successfully added. v6.0.1
[19-08-21 08:56:50.375] (CLI) Prepare Project for Platform - ios
[19-08-21 08:57:20.477] (CLI) Preparing project...
[19-08-21 08:57:33.894] (CLI) Hash: 7b2f90d5b50178cb7f9d
[19-08-21 08:57:33.894] (CLI) Version: webpack 4.27.1
[19-08-21 08:57:33.894] (CLI) Time: 10055ms
[19-08-21 08:57:33.894] (CLI) Built at: 08/20/2019 11:57:40 PM
[19-08-21 08:57:33.894] (CLI) Asset Size Chunks Chunk Names
[19-08-21 08:57:33.894] (CLI) bundle.js 61.8 KiB bundle [emitted] bundle
[19-08-21 08:57:33.894] (CLI) fonts/FontAwesome.ttf 162 KiB [emitted]
[19-08-21 08:57:33.894] (CLI) package.json 81 bytes [emitted]
[19-08-21 08:57:33.894] (CLI) runtime.js 71.4 KiB runtime [emitted] runtime
[19-08-21 08:57:33.894] (CLI) tns_modules/tns-core-modules/inspector_modules.js 643 bytes tns_modules/tns-core-modules/inspector_modules [emitted] tns_modules/tns-core-modules/inspector_modules
[19-08-21 08:57:33.894] (CLI) vendor.js 3.84 MiB vendor [emitted] vendor
[19-08-21 08:57:33.894] (CLI) Entrypoint bundle = runtime.js vendor.js bundle.js
[19-08-21 08:57:33.894] (CLI) Entrypoint tns_modules/tns-core-modules/inspector_modules = runtime.js vendor.js tns_modules/tns-core-modules/inspector_modules.js
[19-08-21 08:57:33.894] (CLI) [./app.scss] 19.8 KiB {bundle} [built]
[19-08-21 08:57:33.894] (CLI) [./main.ts] 926 bytes {bundle} [built]
[19-08-21 08:57:33.894] (CLI) [./package.json] 73 bytes {bundle} {tns_modules/tns-core-modules/inspector_modules} [optional] [built]
[19-08-21 08:57:33.894] (CLI) + 173 hidden modules
[19-08-21 08:57:33.894] (CLI) ERROR in src/app/foobar/bar-foobar/bar-foobar.component.ts(63,25): error TS2339: Property 'ios' does not exist on type 'Observable'.
[19-08-21 08:57:33.894] (CLI) src/app/foobar/bar-foobar/bar-foobar.component.ts(65,25): error TS2339: Property 'android' does not exist on type 'Observable'.
[19-08-21 08:57:33.894] (CLI) src/app/foobar/bar-foobar/bar-foobar.component.ts(67,25): error TS2339: Property 'android' does not exist on type 'Observable'.
[19-08-21 08:57:33.894] (CLI) src/app/foobar/bar-foobar/bar-foobar.component.ts(67,118): error TS2304: Cannot find name 'android'.
[19-08-21 08:57:33.894] (CLI) Webpack compilation complete.
[19-08-21 08:57:33.894] (CLI) Executing webpack failed with exit code 2.
[19-08-21 08:57:33.894] (CLI) # tns prepare
[19-08-21 08:57:33.894] (CLI) ### Description
[19-08-21 08:57:33.894] (CLI) Starts a Webpack compilation and prepares the app's App_Resources and the plugins platforms directories. The output is generated in a subdirectory for the selected target platform in the platforms directory. This lets you build the project for the selected platform. You must specify the target platform for which you want to prepare your project.
[19-08-21 08:57:33.894] (CLI) When running this command the HMR (Hot Module Replacement) is not enabled by default. In case you want to enable HMR, you can pass --hmr flag.
[19-08-21 08:57:33.894] (CLI) ### Commands
[19-08-21 08:57:33.894] (CLI) ┌─────────┬──────────────────────────┐
[19-08-21 08:57:33.894] (CLI) │ Usage │ Synopsis │
[19-08-21 08:57:33.894] (CLI) │ General │ $ tns prepare <Platform> │
[19-08-21 08:57:33.894] (CLI) └─────────┴──────────────────────────┘
[19-08-21 08:57:33.894] (CLI) ### Arguments
[19-08-21 08:57:33.894] (CLI) <Platform> is the target mobile platform for which you want to prepare your project. You can set the following target platforms.
[19-08-21 08:57:33.894] (CLI) * android - Prepares your project for an Android build.
[19-08-21 08:57:33.894] (CLI) * ios - Prepares your project for an iOS build.
[19-08-21 08:57:33.894] (CLI) ### Options
[19-08-21 08:57:33.894] (CLI) * --hmr - Enables the hot module replacement (HMR) feature.
[19-08-21 08:57:33.894] (CLI) * --force - If set, skips the application compatibility checks and forces npm i to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring tns migrate.
[19-08-21 08:57:35.416] (CLI) Executing webpack failed with exit code 2.
[19-08-21 08:57:43.483] Build step completed.
[19-08-21 08:57:43.489] (CLI) Unable to apply changes on device: 709dacd534f7bbb357482d696468f8efbd5888ac. Error is: Build failed. Reason is: 'Build failed with error code 2'. Additional information: [00:00:49.725] [WARN] Executing webpack failed with exit code 2.
[19-08-21 08:57:43.489] (CLI) [00:00:51.335] [ERROR] Executing webpack failed with exit code 2.
[19-08-21 08:57:43.489] (CLI) 'Build failed with error code 2'..
[19-08-21 08:57:43.494] Error detected during LiveSync on 709dacd534f7bbb357482d696468f8efbd5888ac for C:\Users\usr\Documents\ns\acmeapp. Error: Build failed. Reason is: 'Build failed with error code 2'. Additional information: [00:00:49.725] [WARN] Executing webpack failed with exit code 2.
[00:00:51.335] [ERROR] Executing webpack failed with exit code 2.
'Build failed with error code 2'.
[19-08-21 08:57:43.501] Stopped LiveSync on 709dacd534f7bbb357482d696468f8efbd5888ac for C:\Users\usr\Documents\ns\acmeapp.
And I've pinned the suspect - this started after I installed Angular CLI, but now even if I uninstall Angular CLI, error remains and I cannot use NativeScript!
来源:https://stackoverflow.com/questions/57553872/nativescript-build-failed-with-error-code-2