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 Module not found: Error: Can't resolve 'fs' #8357
Comments
|
Same here |
|
I've spent some time trying to debug this, and no matter what, if I update the |
|
Any news on this issue ? |
|
I got the same problem with the jsonpath (npm: "jsonpath": "^1.0.0") library. ERROR in ./node_modules/jsonpath/lib/grammar.js |
|
same problem here |
|
for my little problem with the jsonpath library a workaround for the issue is using: |
|
Same problem, any news? |
|
Hello guys same problem here any news ? |
|
same problem,need someone has been resolved |
|
I had the same error after running If the editor is complaining about missing types for |
|
Same problem here !! Any news ?? |
|
thanks @kevinkuszyk, |
|
I had a |
|
I believe a stray |
|
I have no "import 'jasmine'" in my tests Perhaps the issue is still open & marked as broken/urgent so probably need to wait..? |
|
After upgrading to angular |
|
What worked for me is adding the following to karma.conf.js
Hope it helps someone. |
|
@SearchingSoul ,I would like to sincerely thank you for your help.It's work for me |
|
Here, with Angular 5.2, Angular CLI 1.6.4, with no reference to Cleaning caches and reinstalling NPM modules did not help. |
|
I think this is the issue of Webpack, see this issue webpack-contrib/css-loader#447 , and @SearchingSoul 's configuration solves it. |
|
I have suddenly started getting the same issue today after removing lock files, with CLI 1.6.6. The only thing that helped me is the trick with "karma.conf.js" mentioned above: |
|
I had the same error today AGAIN. Now, I get the code shouldn't wok in this scenario, but it would be nice to have more indicative message. |
|
@SearchingSoul the webpack: { node: { fs: 'empty', } } sort of get rid of the fs error but when I run ng test the chrome test window simply not starting. And returns to command prompt. And the ng test will keep trying to start again and again endlessly. Any thoughts? BTW, I am not using webpage but angular-cli. |
|
@ravivit9 , its only supposed to take care of the 'fs' error. Other errors could be due to other reasons. Yours looks like something to do with your karma |
|
Hi All, |
|
Can't resolve 'child_process' it too have problem I set output |
|
@havart pointed me in the right direction. My errors were caused by importing the wrong EventEmitter in a component: |
This fixes the following errors: |
|
Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version. If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. |
This worked for me |
|
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. |

Bug Report or Feature Request (mark with an
x)Versions.
Angular CLI: 1.5.0
Node: 9.0.0
OS: win32 x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.0
typescript: 2.4.2
webpack: 3.8.1
Repro steps.
ng test
Omits the following error:
ERROR in ./node_modules/fs.realpath/index.js
Module not found: Error: Can't resolve 'fs' in XXXX\node_modules\fs.realpath'
@ ./node_modules/fs.realpath/index.js 8:9-22
@ ./node_modules/jasmine/node_modules/glob/sync.js
@ ./node_modules/jasmine/node_modules/glob/glob.js
@ ./node_modules/jasmine/lib/jasmine.js
@ ./src/client/app/account/login/login.component.spec.ts
@ ./src/client .spec.ts$
@ ./src/client/test.ts
ERROR in ./node_modules/fs.realpath/old.js
Module not found: Error: Can't resolve 'fs' in 'XXXX\node_modules\fs.realpath'
@ ./node_modules/fs.realpath/old.js 24:9-22
@ ./node_modules/fs.realpath/index.js
@ ./node_modules/jasmine/node_modules/glob/sync.js
@ ./node_modules/jasmine/node_modules/glob/glob.js
@ ./node_modules/jasmine/lib/jasmine.js
@ ./src/client/app/account/login/login.component.spec.ts
@ ./src/client .spec.ts$
@ ./src/client/test.ts
ERROR in ./node_modules/jasmine/node_modules/glob/sync.js
Module not found: Error: Can't resolve 'fs' in 'XXXX\node_modules\jasmine\node_modules\glob'
@ ./node_modules/jasmine/node_modules/glob/sync.js 4:9-22
@ ./node_modules/jasmine/node_modules/glob/glob.js
@ ./node_modules/jasmine/lib/jasmine.js
@ ./src/client/app/account/login/login.component.spec.ts
@ ./src/client .spec.ts$
@ ./src/client/test.ts
ERROR in ./node_modules/jasmine/node_modules/glob/glob.js
Module not found: Error: Can't resolve 'fs' inXXXX\node_modules\jasmine\node_modules\glob'
@ ./node_modules/jasmine/node_modules/glob/glob.js 43:9-22
@ ./node_modules/jasmine/lib/jasmine.js
@ ./src/client/app/account/login/login.component.spec.ts
@ ./src/client .spec.ts$
@ ./src/client/test.ts
ERROR in ./node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core.js
Module not found: Error: Can't resolve 'fs' in 'XXXX\node_modules\jasmine\node_modules\jasmine-core\lib'
@ ./node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core.js 5:9-22
@ ./node_modules/jasmine/lib/jasmine.js
@ ./src/client/app/account/login/login.component.spec.ts
@ ./src/client .spec.ts$
@ ./src/client/test.ts
Desired functionality.
Run the tests
Mention any other details that might be useful.
It happened when I upgraded from cli 1.47 to 1.5.0.
Jasmine packages:
"jasmine": "^2.8.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0"
Karma packages:
"karma": "~1.5.0",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.0.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-junit-reporter": "^1.2.0",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.4",
The text was updated successfully, but these errors were encountered: