没有导出的成员/节点模块 [英] No Exported Member / Node Modules
问题描述
我只是使用在此处找到的5分钟快速入门来启动Angular 2/Typescript.我遇到了一个看似常见的问题,但可能有所不同.我遇到了各种各样的无出口会员"问题.例子:
I am just starting Angular 2 / Typescript using the 5 Minute Quickstart found here. I've run into what looks to be a common problem, but maybe a bit different. I am encountering all sorts of "No Exported Member" problems. Examples:
来自app.module.ts:
From app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
返回
...node_modules/@angular2/core/index" has no exported member 'NgModule'.
和
...@angular/platform-browser/index" has no exported member 'BrowserModule'.
并且来自main.ts:
And from main.ts:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
抛出:
...@angular/platform-browser-dynamic/index" has no exported member 'platformBrowserDynamic'.
我正在运行节点版本4.4.7和npm版本3.10.5.
I am running node version 4.4.7 and npm version 3.10.5.
我知道,在本教程的上下文中,通过将node或npm回滚到与本教程相关的版本,可以解决这些问题.我想我更想解释的是如何使教程中的代码与当前版本的节点相关.
I understand that these are probably resolvable in the context of the tutorial by rolling back node or npm to version relevant to the tutorial. I guess what I would prefer to have is an explanation of how to make the code from the tutorial relevant to the current versions of node.
ETA:这些错误发生在编译时,而不是执行时.
ETA: These errors occur at compilation, not execution.
推荐答案
NgModule
类是通过node_modules/@angular/core/index.d.ts
文件从node_modules/@angular/core/src/metadata.d.ts
文件导出的.
The NgModule
class is exported from the node_modules/@angular/core/src/metadata.d.ts
file through the node_modules/@angular/core/index.d.ts
one.
我想知道您是否在tsconfig.json
文件中正确指定了moduleResolution
属性:
I wonder if you specify correctly the moduleResolution
property in your tsconfig.json
file:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node", // <-----
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
}
这篇关于没有导出的成员/节点模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!