简体   繁体   English

错误:无法解析'child_process'Angular-cli

[英]Error: Can't resolve 'child_process' Angular-cli

I generated a new application using angular-cli and added few components. 我使用angular-cli生成了一个新的应用程序并添加了一些组件。 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 操作系统:Ubuntu 16.04 LTS Angular版本是:5.0.2节点: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. 由于我没有编写任何测试用例,这对我没有帮助。

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. 我正在从selenium而不是angular-core中添加一些事件给组件和visual studio代码导入的事件发射器。

deleted this 删除了这个

import { EventEmitter } from 'selenium-webdriver';

and updated this: 并更新了这个:

import { Component, OnInit, Input, EventEmitter } from '@angular/core';

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 . 好吧,我没有太多的上下文,因为你刚发布错误,但这可能类似于Webpack和TypeScript:无法解析node.d.ts中的模块'child_process'

Adding "target": "node" to your webpack configs could resolve the issue. 在您的webpack配置中添加"target": "node"可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM