Skip to content
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

ng test fails on angular CLI project #863

Closed
aecz opened this issue Jul 27, 2017 · 11 comments
Closed

ng test fails on angular CLI project #863

aecz opened this issue Jul 27, 2017 · 11 comments

Comments

@aecz
Copy link
Contributor

aecz commented Jul 27, 2017

pnpm version: 1.8.1

Code to reproduce the issue:

pnpm i -g @angular/cli@1.2.5
ng new test-pnpm --skip-install
cd test-pnpm
pnpm i
ng test

Expected behavior:

Tests are run successfully and start watching files.

Actual behavior:

ng test

Cannot find module 'source-map-support'
Error: Cannot find module 'source-map-support'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.resolve (internal/module.js:27:19)
    at init (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/@angular/cli/1.2.5/node_modules/@angular/cli/plugins/karma.js:61:46)
    at Array.invoke (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/di/0.0.1/node_modules/di/lib/injector.js:75:15)
    at Injector.get (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/di/0.0.1/node_modules/di/lib/injector.js:48:43)
    at /Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/karma/1.7.0/node_modules/karma/lib/server.js:143:20
    at Array.forEach (native)
    at Server._start (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/karma/1.7.0/node_modules/karma/lib/server.js:142:21)
    at Injector.invoke (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/di/0.0.1/node_modules/di/lib/injector.js:75:15)
    at Server.start (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/karma/1.7.0/node_modules/karma/lib/server.js:103:18)
    at Promise (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/@angular/cli/1.2.5/node_modules/@angular/cli/tasks/test.js:35:25)
    at Class.run (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/@angular/cli/1.2.5/node_modules/@angular/cli/tasks/test.js:15:16)
    at Class.run (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/@angular/cli/1.2.5/node_modules/@angular/cli/commands/test.js:104:25)
    at resolve (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/@angular/cli/1.2.5/node_modules/@angular/cli/ember-cli/lib/models/command.js:273:20)
    at Class.validateAndRun (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/@angular/cli/1.2.5/node_modules/@angular/cli/ember-cli/lib/models/command.js:251:12)
    at Promise.resolve.then.then (/Users/aecz/test-pnpm/node_modules/.registry.npmjs.org/@angular/cli/1.2.5/node_modules/@angular/cli/ember-cli/lib/cli/cli.js:157:24)
npm ERR! Test failed.  See above for more details.

Additional information:

  • node -v prints: 6.11.0
  • Windows, OS X, or Linux?: OS X Sierra
@zkochan
Copy link
Member

zkochan commented Jul 27, 2017

I'll check tonight but I have a feeling that this is caused by the same issue as #857. I contributed a fix to resolve which was published yesterday. It is turned off by default for now (see browserify/resolve#131) but will be turned on in next major version. That should solve a lot of issues that pnpm has in the ecosystem

@zkochan
Copy link
Member

zkochan commented Jul 27, 2017

this issue is happening because @angular/cli tries to resolve source-map-support even though source-map-support is not in its dependencies.

It works with npm because it flattens dependencies and source-map-support is hoisted from karma-source-map-support.

We'll have to make a small PR to @angular/cli in order to fix this.

aecz added a commit to aecz/angular-cli that referenced this issue Jul 28, 2017
Angular CLI relies on a flat dependency tree to require source-map-support which is a problem when using a nested tree like pnpm is doing. Also it could be a problem if karma-source-map-support remove/change its source-map-support dependency.
pnpm/pnpm#863
aecz added a commit to aecz/angular-cli that referenced this issue Jul 28, 2017
Angular CLI relies on a flat dependency tree to require source-map-support which is a problem when using a nested tree like pnpm is doing. Also it could be a problem if karma-source-map-support remove/change its source-map-support dependency.
pnpm/pnpm#863
aecz added a commit to aecz/angular-cli that referenced this issue Jul 28, 2017
karma plugin relies on source-map-support being a dependency of karma-source-map-support and npm 3+ flat dependency tree.

pnpm/pnpm#863
@aecz
Copy link
Contributor Author

aecz commented Jul 28, 2017

PR done. angular/angular-cli#7191
I fear it can happen with other packages though. I have seen other packages telling you to update to npm 3+ because of the flat tree. Any option to have pnpm detect if a package needs to be flattened?

@zkochan
Copy link
Member

zkochan commented Jul 28, 2017

Thanks for making the PR!

There is no such option in pnpm currently but I've been working on a tool that should do that: node-modules-check. I'll have to check if it works and publish it

filipesilva pushed a commit to angular/angular-cli that referenced this issue Jul 31, 2017
karma plugin relies on source-map-support being a dependency of karma-source-map-support and npm 3+ flat dependency tree.

pnpm/pnpm#863
hansl pushed a commit to angular/angular-cli that referenced this issue Aug 3, 2017
karma plugin relies on source-map-support being a dependency of karma-source-map-support and npm 3+ flat dependency tree.

pnpm/pnpm#863
hansl pushed a commit to angular/angular-cli that referenced this issue Aug 3, 2017
karma plugin relies on source-map-support being a dependency of karma-source-map-support and npm 3+ flat dependency tree.

pnpm/pnpm#863
@aecz
Copy link
Contributor Author

aecz commented Aug 11, 2017

Solved but now i get another error:

test-pnpm$ ng test
ERROR [config]: Error in config file!
{ Error: Cannot find module 'enhanced-resolve/lib/ModulesInRootPlugin'

Should i close this issue and open a new one?

@zkochan
Copy link
Member

zkochan commented Aug 11, 2017

As you wish. I created a separate label for grouping these issues.

@aecz
Copy link
Contributor Author

aecz commented Aug 14, 2017

PR created. angular/angular-cli#7385

@whyboris
Copy link

I just tried out pnpm on an Angular project and it gave the error:
Cannot find module 'enhanced-resolve/lib/ModulesInRootPlugin'
I added "enhanced-resolve": "3.4.1", to my package.json and the error is gone.
Thank you @aecz for being on top of this -- looks like the Angular team will address the error I had and I'll no longer need to manually add enhanced-resolve to my project 👍

@zkochan
Copy link
Member

zkochan commented Sep 2, 2017

@aecz do you have twitter? I want to mention you in an article (to say thank you). Otherwise I'll just drop a link to your github page

@aecz
Copy link
Contributor Author

aecz commented Sep 3, 2017

@zkochan i do not use my Twitter account. Github profile is fine. Thanks for the mention.

@aecz
Copy link
Contributor Author

aecz commented Dec 15, 2017

Cannot find module 'source-map-support' error solved with Angular CLI 1.3.2.

@aecz aecz closed this as completed Dec 15, 2017
dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this issue Apr 23, 2018
…r#7191)

karma plugin relies on source-map-support being a dependency of karma-source-map-support and npm 3+ flat dependency tree.

pnpm/pnpm#863
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants