当app.component.ts重命名为app.ts时,Angular2导入问题

时间:2016-04-16 14:35:06

标签: typescript angular

我正在使用Typescript进行Angular2。

在创建文件app.component.ts后,按照5分钟的快速入门教程,我尝试将其重命名为app.ts

因此要包含此文件,我必须更新main.ts中的import语句

原始陈述:import {AppComponent} from './app.component';

现在,如果我将其更改为import {AppComponent} from './app';,则无效。

我在这里做错了什么?

编辑: npm-debug.log

中记录的错误消息
19 silly fetchPackageMetaData Error: Registry returned 404 for GET on https://registry.npmjs.org/ang2
19 silly fetchPackageMetaData     at makeError (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\lib\request.js:264:12)
19 silly fetchPackageMetaData     at CachingRegistryClient.<anonymous> (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\lib\request.js:242:14)
19 silly fetchPackageMetaData     at Request._callback (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\lib\request.js:172:14)
19 silly fetchPackageMetaData     at Request.self.callback (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\request\request.js:199:22)
19 silly fetchPackageMetaData     at emitTwo (events.js:100:13)
19 silly fetchPackageMetaData     at Request.emit (events.js:185:7)
19 silly fetchPackageMetaData     at Request.<anonymous> (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\request\request.js:1036:10)
19 silly fetchPackageMetaData     at emitOne (events.js:95:20)
19 silly fetchPackageMetaData     at Request.emit (events.js:182:7)
19 silly fetchPackageMetaData     at IncomingMessage.<anonymous> (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\request\request.js:963:12)
19 silly fetchPackageMetaData  error for ang2 { [Error: Registry returned 404 for GET on https://registry.npmjs.org/ang2] pkgid: 'ang2', statusCode: 404, code: 'E404' }
20 verbose stack Error: Registry returned 404 for GET on https://registry.npmjs.org/ang2
20 verbose stack     at makeError (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\lib\request.js:264:12)
20 verbose stack     at CachingRegistryClient.<anonymous> (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\lib\request.js:242:14)
20 verbose stack     at Request._callback (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\lib\request.js:172:14)
20 verbose stack     at Request.self.callback (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\request\request.js:199:22)
20 verbose stack     at emitTwo (events.js:100:13)
20 verbose stack     at Request.emit (events.js:185:7)
20 verbose stack     at Request.<anonymous> (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\request\request.js:1036:10)
20 verbose stack     at emitOne (events.js:95:20)
20 verbose stack     at Request.emit (events.js:182:7)
20 verbose stack     at IncomingMessage.<anonymous> (C:\Users\Manmeet\AppData\Roaming\npm\node_modules\npm\node_modules\request\request.js:963:12)

编辑2 :将导入语句更改为import {AppComponent} from './app.';可解决问题。

为什么要修复它?

0 个答案:

没有答案