-
Notifications
You must be signed in to change notification settings - Fork 12k
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
karma errors when using non-relative path import #3586
Comments
Yeah, that's because .beta-22-1 always compiles using AOT (that's a bug).
|
@rolandoldengarm this way does fix the issue, but it's somehow inconvenient because I can't put a wildcard here. Hopefully this is not the best choice... |
Yeah it's not optimal, hope there is a better solution :) |
I too have something like that, #3533 |
Still having the same issues with beta.24. Does somebody has any tips for getting this to work, besides writing every import to browser: { ... } inside package.json? As @SteveZheng-BSFT already said: It is working with ng serve. Only ng test fails when resolving the modules. |
Me too. |
Same for me. |
Hi! I created a temporary workaround to fix this problem. New filesSave the code of my gist to a file named Create three more files inside the same folder:
require('./common').updatePackageFile(true);
require('./common').updatePackageFile(false);
require('./common').revertPackageFile(); package.json scriptsUpdate your package.json like this: {
"scripts": {
"test-single-run": "npm run prepare-test && npm run test -- --single-run --progress=False && npm run revert-test",
"prepare-test": "node tools/ng-test/prepare.js",
"revert-test": "node tools/ng-test/revert.js",
"update-test": "node tools/ng-test/update.js",
...
},
...
}
To simplify this process, run I hope, someone is successful with that too. Have fun! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
OS?
Versions.
Repro steps.
The log given by the failure.
ERROR in ./src/app/cart/cart-summary/cart-summary.component.ts Module not found: Error: Can't resolve 'services/cart' in '/Users/stevezheng/webstorm/mai/src/app/cart/cart-summary'
@ ./src/app/cart/cart-summary/cart-summary.component.ts 12:13-37
@ ./src/app/cart/cart-summary/cart-summary.component.spec.ts
@ ./src .spec.ts
@ ./src/test.ts
Chrome 54.0.2840 (Mac OS X 10.11.6) ERROR
Uncaught Error: Cannot find module "services/cart"
at webpack:///Users/stevezheng/webstorm/mai/src/app/cart/cart-summary/cart-summary.component.ts:3:0 <- src/test.ts:53357
Other details:
There's no error when I import "services/cart" in my feature.module.ts, but do throw errors when import in xxx.component.ts.
Again, there's no error for running app but runing test.
Do I need to config more to make test work or this is a bug?
I created a sample for you testing:
https://github.com/SteveZheng-BSFT/karma-error-sample
After changing to relative path, ng test has no errors.
The text was updated successfully, but these errors were encountered: