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

ERROR in ./node_modules/electron/index.js Module not found: Error: Can't resolve 'fs' #314

Closed
dalenguyen opened this issue Feb 28, 2019 · 6 comments

Comments

@dalenguyen
Copy link

It shows an error when I try to run npm test. Any ideas?

ERROR in ./node_modules/electron/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/dnguyen/Documents/projects/random/angular-electron/node_modules/electron'
resolve 'fs' in '/Users/dnguyen/Documents/projects/random/angular-electron/node_modules/electron'
  Parsed request is a module
  using description file: /Users/dnguyen/Documents/projects/random/angular-electron/node_modules/electron/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      looking for modules in /Users/dnguyen/Documents/projects/random/angular-electron
        using description file: /Users/dnguyen/Documents/projects/random/angular-electron/package.json (relative path: .)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /Users/dnguyen/Documents/projects/random/angular-electron/package.json (relative path: ./fs)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/dnguyen/Documents/projects/random/angular-electron/fs doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/dnguyen/Documents/projects/random/angular-electron/fs.ts doesn't exist
            .tsx
              Field 'browser' doesn't contain a valid alias configuration
              /Users/dnguyen/Documents/projects/random/angular-electron/fs.tsx doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /Users/dnguyen/Documents/projects/random/angular-electron/fs.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/dnguyen/Documents/projects/random/angular-electron/fs.js doesn't exist
            as directory
              /Users/dnguyen/Documents/projects/random/angular-electron/fs doesn't exist
      /Users/dnguyen/Documents/projects/random/angular-electron/node_modules/electron/node_modules doesn't exist or is not a directory
      /Users/dnguyen/Documents/projects/random/angular-electron/node_modules/node_modules doesn't exist or is not a directory
      /Users/dnguyen/Documents/projects/random/node_modules doesn't exist or is not a directory
      /Users/dnguyen/Documents/projects/node_modules doesn't exist or is not a directory
      /Users/dnguyen/Documents/node_modules doesn't exist or is not a directory
      /Users/dnguyen/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /Users/dnguyen/Documents/projects/random/angular-electron/node_modules
        using description file: /Users/dnguyen/Documents/projects/random/angular-electron/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /Users/dnguyen/Documents/projects/random/angular-electron/package.json (relative path: ./node_modules/fs)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/dnguyen/Documents/projects/random/angular-electron/node_modules/fs doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/dnguyen/Documents/projects/random/angular-electron/node_modules/fs.ts doesn't exist
            .tsx
              Field 'browser' doesn't contain a valid alias configuration
              /Users/dnguyen/Documents/projects/random/angular-electron/node_modules/fs.tsx doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /Users/dnguyen/Documents/projects/random/angular-electron/node_modules/fs.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/dnguyen/Documents/projects/random/angular-electron/node_modules/fs.js doesn't exist as directory
              /Users/dnguyen/Documents/projects/random/angular-electron/node_modules/fs doesn't exist
[/Users/dnguyen/Documents/projects/random/angular-electron/fs]
[/Users/dnguyen/Documents/projects/random/angular-electron/fs.ts]
[/Users/dnguyen/Documents/projects/random/angular-electron/fs.tsx]
[/Users/dnguyen/Documents/projects/random/angular-electron/fs.mjs]
[/Users/dnguyen/Documents/projects/random/angular-electron/fs.js]
[/Users/dnguyen/Documents/projects/random/angular-electron/node_modules/electron/node_modules]
[/Users/dnguyen/Documents/projects/random/angular-electron/node_modules/node_modules]
[/Users/dnguyen/Documents/projects/random/node_modules]
[/Users/dnguyen/Documents/projects/node_modules]
[/Users/dnguyen/Documents/node_modules]
[/Users/dnguyen/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/dnguyen/Documents/projects/random/angular-electron/node_modules/fs]
[/Users/dnguyen/Documents/projects/random/angular-electron/node_modules/fs.ts]
[/Users/dnguyen/Documents/projects/random/angular-electron/node_modules/fs.tsx]
[/Users/dnguyen/Documents/projects/random/angular-electron/node_modules/fs.mjs]
[/Users/dnguyen/Documents/projects/random/angular-electron/node_modules/fs.js]
 @ ./node_modules/electron/index.js 1:9-22
 @ ./src/app/providers/database.service.ts
 @ ./src/app/app.component.ts
 @ ./src/app/app.component.spec.ts
 @ ./src sync \.spec\.ts$
 @ ./src/test.ts
@Hariskool
Copy link

Did you add " import * as fs from 'fs';" this in your maint.ts

@dalenguyen
Copy link
Author

@Hariskool, I just tried with the import * as fs from 'fs';. It shows the same error.

@Hariskool
Copy link

fs module is part of node's core modules. Update or reinstall your node js..

@Hariskool
Copy link

Give a look at this angular/angular-cli#10681

@brucebrit
Copy link

I encounter the same issue when i run npm test. Hariskool, u manage to resolve this issue?

@brucebrit
Copy link

The weird thing is that it only happen when i run npm test. Running the application normally dont trigger any issue

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

No branches or pull requests

4 participants