Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Can't resolve 'child_process' Angular-cli

I generated a new application using angular-cli and added few components. I haven't added any test cases. when I try to run/build the app, I get the following lengthy error message:

ERROR in ./node_modules/selenium-webdriver/firefox/binary.js
Module not found: Error: Can't resolve 'child_process' in '/home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/firefox'
resolve 'child_process' in '/home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/firefox'
  Parsed request is a module
  using description file: /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/package.json (relative path: ./firefox)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/package.json (relative path: ./firefox)
    resolve as module
      /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/firefox/node_modules doesn't exist or is not a directory
      /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/node_modules doesn't exist or is not a directory
      /home/myName/PROJECTS/MEAN/fruit-stall/node_modules doesn't exist or is not a directory
      /home/myName/PROJECTS/MEAN/node_modules doesn't exist or is not a directory
      /home/myName/PROJECTS/node_modules doesn't exist or is not a directory
      /home/myName/node_modules doesn't exist or is not a directory
      /home/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/node_modules
        using description file: /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/package.json (relative path: ./node_modules)

Please find the detailed dump here.

OS: Ubuntu 16.04 LTS Angular version is: 5.0.2 node: 9.2.0

I also found a similar question being asked here, but it is related to the test cases. Since I haven't written any test cases, that did not help me.

like image 624
Shrinivas Avatar asked Nov 20 '17 07:11

Shrinivas


2 Answers

Got the culprit!

I was adding some events to one of the component and visual studio code imported event emitter from selenium instead of angular-core.

deleted this

import { EventEmitter } from 'selenium-webdriver';

and updated this:

import { Component, OnInit, Input, EventEmitter } from '@angular/core';
like image 199
Shrinivas Avatar answered Oct 13 '22 21:10

Shrinivas


Well, I don't have too much context here since you just posted errors, but this could be similar to Webpack and TypeScript: Cannot resolve module 'child_process' in node.d.ts.

Adding "target": "node" to your webpack configs could resolve the issue.

like image 1
Jack Ryan Avatar answered Oct 13 '22 20:10

Jack Ryan