Skip to content

ng build => Cannot read property 'provide' of null #3834

@bastienJS

Description

@bastienJS

Please provide us with the following information:

OS?

Win 10 x64

Versions.

angular-cli: 1.0.0-beta.24
node: 6.2.2
os: win32 x64
@angular/common: 2.4.1
@angular/compiler: 2.4.1
@angular/core: 2.4.1
@angular/forms: 2.4.1
@angular/http: 2.4.1
@angular/platform-browser: 2.4.1
@angular/platform-browser-dynamic: 2.4.1
@angular/router: 3.4.1
"typescript": "^2.0.10"
"angular-cli": "^1.0.0-beta.24",

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
I updated from angular 2.0.1 and angular-cli 1.0.0-beta 18 (I assume...) to the latest angular and angular-cli versions

Mention any other details that might be useful.

  • I am not creating components to be used by others.
    This is what I did:

C:\temp\myapp>ng build
Hash: 5b4b8769f714f025441e
Time: 25174ms
chunk {0} main.bundle.js, main.bundle.map (main) 133 kB {2} [initial] [rendered]
chunk {1} styles.bundle.css, styles.bundle.map, styles.bundle.map (styles) 152 kB {3} [initial] [rendered]
chunk {2} vendor.bundle.js, vendor.bundle.map (vendor) 3.63 MB [initial] [rendered]
chunk {3} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]

ERROR in Cannot read property 'provide' of null
 
ERROR in ./src/app/tests/list/tests-list.component.ts
Module not found: Error: Can't resolve 'tests-list.component.html' in 'C:\temp\myapp\src\app\tests\list'
 @ ./src/app/tests/list/tests-list.component.ts 33:22-64
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./src/app/tests/list/tests-list.component.ts
Module not found: Error: Can't resolve 'tests-list.component.css' in 'C:\temp\myapp\src\app\tests\list'
 @ ./src/app/tests/list/tests-list.component.ts 34:21-62
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

AFTER ng build I did npm start to get maybe other errors whats going on:

Uncaught Error: Cannot find module "tests-list.component.html"
    at webpackMissingModule (tests-list.component.ts:8) [<root>]
    at :4200/main.bundle.js:1678:195 [<root>]
    at Object.684 (tests-list.component.ts:41) [<root>]
    at __webpack_require__ (bootstrap d782c45…:52) [<root>]
    at Object.669 (subject.ts:11) [<root>]
    at __webpack_require__ (bootstrap d782c45…:52) [<root>]
    at Object.679 (weightedgrade.ts:4) [<root>]
    at __webpack_require__ (bootstrap d782c45…:52) [<root>]
    at Object.543 (src async:7) [<root>]
    at __webpack_require__ (bootstrap d782c45…:52) [<root>]
    at Object.1181 (main.bundle.js:7) [<root>]
    at __webpack_require__ (bootstrap d782c45…:52) [<root>]
    at webpackJsonpCallback (bootstrap d782c45…:23) [<root>]
    at :4200/main.bundle.js:1:1 [<root>]
client?93b6:38[WDS] Errors while compiling.
client?93b6:80Cannot read property 'provide' of null
errors @ client?93b6:80
client?93b6:80./src/app/tests/list/tests-list.component.ts
Module not found: Error: Can't resolve 'tests-list.component.html' in 'C:\temp\myapp\src\app\tests\list'
resolve 'tests-list.component.html' in 'C:\temp\myapp\src\app\tests\list'
  Parsed request is a module
  using description file: C:\temp\myapp\package.json (relative path: ./src/app/tests/list)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: C:\temp\myapp\package.json (relative path: ./src/app/tests/list)
    resolve as module
      looking for modules in C:\temp\myapp\node_modules
        using description file: C:\temp\myapp\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: C:\temp\myapp\package.json (relative path: ./node_modules)
          using description file: C:\temp\myapp\package.json (relative path: ./node_modules/tests-list.component.html)
            as directory
              C:\temp\myapp\node_modules\tests-list.component.html doesn't exist
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              C:\temp\myapp\node_modules\tests-list.component.html doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              C:\temp\myapp\node_modules\tests-list.component.html.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              C:\temp\myapp\node_modules\tests-list.component.html.js doesn't exist
[C:\temp\myapp\node_modules\tests-list.component.html]
[C:\temp\myapp\node_modules\tests-list.component.html]
[C:\temp\myapp\node_modules\tests-list.component.html.ts]
[C:\temp\myapp\node_modules\tests-list.component.html.js]
 @ ./src/app/tests/list/tests-list.component.ts 33:22-64
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

Why does webpack think:

Cannot find module "tests-list.component.html"

that my html file is a module?

This is my angular-cli.json but I did not change it afer I updated to angular-/cli new versions:


{
  "project": {
    "version": "1.0.0-beta.24",
    "name": "tgb-ng2"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [],
      "index": "index.html",
      "main": "main.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "mobile": false,
      "styles": [
        "styles.css","../node_modules/bootstrap/dist/css/bootstrap.css"
      ],
      "scripts": [], 
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "addons": [],
  "packages": [],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions