Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JohannesRudolph opened this issue Sep 27, 2016 · 6 comments
Closed

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

JohannesRudolph opened this issue Sep 27, 2016 · 6 comments

Comments

@JohannesRudolph
Copy link
Contributor

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.

@JohannesRudolph
Copy link
Contributor Author

Potentially a duplicate of #2359

@dzonatan
Copy link
Contributor

Warnings about ng2-slim-loading-bar package are shown because that package is missing *.ts files from npm registry while source maps still refers to them. They are ignored in this line.

You should create an issue in akserg/ng2-slim-loading-bar for request of adding typescript files or improving source maps.

@JohannesRudolph
Copy link
Contributor Author

JohannesRudolph commented Sep 27, 2016

Thanks @dzonatan, I will try this! But why does ng build not complain about this when ng test does?

@dzonatan
Copy link
Contributor

Good question. I think the answer is hiding somewhere in webpack configuration since test and serve/build have different configs.

Anyway they're just warnings and your tests should pass.

@filipesilva
Copy link
Contributor

Dupe of #2359. The cause for other warnings are as @dzonatan described.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants