在以下角度组件中
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';