缺少从“量角器”的导入{by}时找不到名称“ require”

时间:2019-02-15 10:27:25

标签: angular protractor

在以下角度组件中

import { Component, OnInit } from '@angular/core';
import { environment } from '../../../environments/environment';

@Component({
  selector: 'test',
  templateUrl: './test.component.html',
  styleUrls: ['./test.component.scss']
   })
export class TestComponent implements OnInit {

  version: string = require( '../../../../package.json').version;
  env: string = environment.env;

  constructor() { }

  ngOnInit() {      
  }

 }

构建解决方案时出现以下错误

src/app/components/test/test.component.ts(12,21): error TS2304: Cannot find name 'require'.

奇怪的是,当我添加以下导入时,问题已解决,但我不知道为什么?

import { by } from 'protractor';

0 个答案:

没有答案