简体   繁体   中英

Electron/Angular app failed to compile because missing http module

I need to work on an Electron/Angular application that was already previously developed, I am just trying to add a feature. The app has not been touched for a while, but now when I try to launch it in development with

ng serve

I get the following error

Your global Angular CLI version (8.3.23) is greater than your local
version (6.0.8). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
 10% building modules 6/6 modules 0 activei 「wds」: Project is running at http://localhost:4200/
i 「wds」: webpack output is served from /
i 「wds」: 404s will fallback to //index.html

Date: 2020-01-21T17:27:12.816Z
Hash: 9ccbd80f9187de6cbb3f
Time: 4077ms
chunk {main} main.js, main.js.map (main) 355 kB [entry] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 354 kB [entry] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 513 kB [entry] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 5.5 kB [initial] [rendered]

WARNING in ./src/styles.scss (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/dist/cjs.js??ref--14-3!./src/styles.sc/styles.scss)
(Emitted value instead of an instance of Error) autoprefixer: D:\Helpful Applications\dispatch-electron\src\styles.scss:24:4: grid-auto-rows is not supported by IE grid-auto-rows is not supported by IE

ERROR in src/environments/environment.prod.ts(1,23): error TS2307: Cannot find module '../../config/http'.
src/environments/environment.ts(5,23): error TS2307: Cannot find module '../../config/http'.
src/environments/environment.ts(6,26): error TS2307: Cannot find module '../../config/http.dev'.

i 「wdm」: Failed to compile.

in my /config/ directory I do not have a http or http.dev directory, I only have http.template.js file that contains this.

module.exports = {
    authUrl: "",
    apiUrl: "",
    logUrl: ""
};

Here is my environment.ts file

// This file can be replaced during build by using the `fileReplacements` array.
// `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.

import * as http from "../../config/http";
import * as devhttp from "../../config/http.dev";

Object.assign(http, devhttp);

export const environment = {
    production: false,
    http: http
};

/*
 * In development mode, to ignore zone related error stack frames such as
 * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can
 * import the following file, but please comment it out in production mode
 * because it will have performance impact when throw error
 */
// import 'zone.js/dist/zone-error';  // Included with Angular CLI.

Here is the angular.json file

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "dispatch-electron": {
            "root": "",
            "sourceRoot": "src",
            "projectType": "application",
            "prefix": "d",
            "schematics": {},
            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:browser",
                    "options": {
                        "outputPath": "dist",
                        "index": "src/index.html",
                        "main": "src/main.ts",
                        "polyfills": "src/polyfills.ts",
                        "tsConfig": "src/tsconfig.app.json",
                        "assets": [
                            "src/favicon.ico",
                            "src/assets"
                        ],
                        "styles": [
                            "src/styles.scss"
                        ],
                        "scripts": []
                    },
                    "configurations": {
                        "production": {
                            "fileReplacements": [
                                {
                                    "replace": "src/environments/environment.ts",
                                    "with": "src/environments/environment.prod.ts"
                                }
                            ],
                            "optimization": true,
                            "outputHashing": "all",
                            "sourceMap": false,
                            "extractCss": true,
                            "namedChunks": false,
                            "aot": true,
                            "extractLicenses": true,
                            "vendorChunk": false,
                            "buildOptimizer": true
                        }
                    }
                },
                "serve": {
                    "builder": "@angular-devkit/build-angular:dev-server",
                    "options": {
                        "browserTarget": "dispatch-electron:build"
                    },
                    "configurations": {
                        "production": {
                            "browserTarget": "dispatch-electron:build:production"
                        }
                    }
                },
                "extract-i18n": {
                    "builder": "@angular-devkit/build-angular:extract-i18n",
                    "options": {
                        "browserTarget": "dispatch-electron:build"
                    }
                },
                "test": {
                    "builder": "@angular-devkit/build-angular:karma",
                    "options": {
                        "main": "src/test.ts",
                        "polyfills": "src/polyfills.ts",
                        "tsConfig": "src/tsconfig.spec.json",
                        "karmaConfig": "src/karma.conf.js",
                        "styles": [
                            "src/styles.scss"
                        ],
                        "scripts": [],
                        "assets": [
                            "src/favicon.ico",
                            "src/assets"
                        ]
                    }
                },
                "lint": {
                    "builder": "@angular-devkit/build-angular:tslint",
                    "options": {
                        "tsConfig": [
                            "src/tsconfig.app.json",
                            "src/tsconfig.spec.json"
                        ],
                        "exclude": [
                            "**/node_modules/**"
                        ]
                    }
                }
            }
        },
        "dispatch-electron-e2e": {
            "root": "e2e/",
            "projectType": "application",
            "architect": {
                "e2e": {
                    "builder": "@angular-devkit/build-angular:protractor",
                    "options": {
                        "protractorConfig": "e2e/protractor.conf.js",
                        "devServerTarget": "dispatch-electron:serve"
                    },
                    "configurations": {
                        "production": {
                            "devServerTarget": "dispatch-electron:serve:production"
                        }
                    }
                },
                "lint": {
                    "builder": "@angular-devkit/build-angular:tslint",
                    "options": {
                        "tsConfig": "e2e/tsconfig.e2e.json",
                        "exclude": [
                            "**/node_modules/**"
                        ]
                    }
                }
            }
        }
    },
    "defaultProject": "dispatch-electron"
}

I do not have a lot of knowledge about this application, so any help would be much appreciated. I just want to get it in a development setting so that I can work on it.

Sounds like the files are missing. Comment out the imports. Next try to figure out the value of http. It could be a boolean but most likely it's an key/value object.

//import * as http from "../../config/http";
//import * as devhttp from "../../config/http.dev";

//Object.assign(http, devhttp);

export const environment = {
    production: false,
    http: http
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM