Skip to content

ng test "Cannot find source file" for npm dependencies #2364

Closed
@JohannesRudolph

Description

@JohannesRudolph

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    OS X El Capitan
  2. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
iDevBook01:context jr$ ng --version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.15
node: 6.3.0
os: darwin x64
  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.
    1. Create a demo project ng new demo
    2. add any npm angular 2 library (e.g. ng2-slim-loading-bar)
    3. edit app.component.spec.ts to import from library (e.g. import { SlimLoadingBarService } from 'ng2-slim-loading-bar';)
    4. run ng test
  2. The log given by the failure. Normally this include a stack trace and some
    more information.
WARNING in ./~/ng2-slim-loading-bar/index.js
Cannot find source file 'index.ts': Error: Can't resolve './index.ts' in '/Users/jr/dev/new-horizon/meshstack-ui/node_modules/ng2-slim-loading-bar'
 @ ./src/app/app.component.ts 9:2511-2542
 @ ./src/app/app.component.spec.ts
 @ ./src \.spec\.ts
 @ ./src/test.ts

WARNING in ./~/ng2-slim-loading-bar/src/slim-loading-bar.component.js
Cannot find source file 'slim-loading-bar.component.ts': Error: Can't resolve './slim-loading-bar.component.ts' in '/Users/jr/dev/new-horizon/meshstack-ui/node_modules/ng2-slim-loading-bar/src'
 @ ./~/ng2-slim-loading-bar/index.js 19:35-78 21:9-52
 @ ./src/app/app.component.spec.ts
 @ ./src \.spec\.ts
 @ ./src/test.ts

WARNING in ./~/ng2-slim-loading-bar/src/slim-loading-bar.service.js
Cannot find source file 'slim-loading-bar.service.ts': Error: Can't resolve './slim-loading-bar.service.ts' in '/Users/jr/dev/new-horizon/meshstack-ui/node_modules/ng2-slim-loading-bar/src'
 @ ./~/ng2-slim-loading-bar/index.js 20:33-74 22:9-50
 @ ./src/app/app.component.spec.ts
 @ ./src \.spec\.ts
 @ ./src/test.ts

WARNING in ./~/ng2-slim-loading-bar/src/slim-loading-bar.utils.js
Cannot find source file 'slim-loading-bar.utils.ts': Error: Can't resolve './slim-loading-bar.utils.ts' in '/Users/jr/dev/new-horizon/meshstack-ui/node_modules/ng2-slim-loading-bar/src'
 @ ./~/ng2-slim-loading-bar/src/slim-loading-bar.component.js 16:31-66
 @ ./~/ng2-slim-loading-bar/index.js
 @ ./src/app/app.component.spec.ts
 @ ./src \.spec\.ts
 @ ./src/test.ts

WARNING in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
45:15 Critical dependency: the request of a dependency is an expression

WARNING in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
57:15 Critical dependency: the request of a dependency is an expression
  1. Mention any other details that might be useful.
    I assume this has something to do with the way test.ts loads libraries/sets up the karma environment. Not sure where to start looking for a fix though.

Thanks! We'll be in touch soon.

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