我使用angular-cli生成了一个新的应用程序并添加了一些组件。我还没有添加任何测试用例。当我尝试运行/构建应用程序时,我收到以下冗长的错误消息:
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)
请查看详细转储here。
操作系统:Ubuntu 16.04 LTS Angular版本是:5.0.2 节点:9.2.0我还发现了一个类似的问题here,但它与测试用例有关。由于我还没有编写任何测试用例,这对我没有帮助。
答案 0 :(得分:20)
罪魁祸首!
我正在从selenium而不是angular-core中添加一些事件给组件和visual studio代码导入的事件发射器。
删除了这个
import { EventEmitter } from 'selenium-webdriver';
并更新了这个:
import { Component, OnInit, Input, EventEmitter } from '@angular/core';
答案 1 :(得分:0)
好吧,由于您刚刚发布了错误,因此我没有太多上下文,但这可能类似于Webpack and TypeScript: Cannot resolve module 'child_process' in node.d.ts。
将"target": "node"
添加到您的webpack配置可以解决问题。