npm 启动我的 Angular2 项目时出现重复的标识符导出错误
Posted
技术标签:
【中文标题】npm 启动我的 Angular2 项目时出现重复的标识符导出错误【英文标题】:Duplicate identifier export error while npm start my Angular2 Project 【发布时间】:2017-08-17 10:23:43 【问题描述】:当我通过 npm start 命令运行我的 Angular2 项目时,我得到 Duplicate identifier export " 错误。我搜索了很多但找不到我的问题的确切解决方案。你可以找到 package.json、typings.json 和 tsconfig。 json 下面。
问候 阿尔珀
package.json
"name": "Angular2SampleProject2",
"version": "1.0.0",
"scripts":
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"e2e": "tsc && concurrently \"http-server -s\" \"protractor
protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"pree2e": "webdriver-manager update",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "tsc && karma start karma.conf.js --single-run",
"tsc": "tsc",
"tsc:w": "tsc -w" ,
"license": "ISC",
"dependencies":
"@angular/common": "2.4.0",
"@angular/compiler": "2.4.0",
"@angular/core": "2.4.0",
"@angular/forms": "2.4.0",
"@angular/http": "2.4.0",
"@angular/platform-browser": "2.4.0",
"@angular/platform-browser-dynamic": "2.4.0",
"@angular/router": "3.4.0",
"angular-in-memory-web-api": "0.2.2",
"systemjs": "0.19.40",
"core-js": "2.4.1",
"reflect-metadata": "0.1.8",
"rxjs": "5.0.1",
"zone.js": "0.7.4"
,
"devDependencies":
"concurrently": "3.1.0",
"lite-server": "2.2.2",
"typescript": "2.0.10",
"canonical-path": "0.0.2",
"http-server": "^0.9.0",
"tslint": "^3.15.1",
"lodash": "^4.16.4",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"@types/node": "6.0.46",
"@types/jasmine": "2.5.36"
tsconfig.json
"compilerOptions":
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
错误信息:
Types of property 'pause' are incompatible.
Type '() => void' is not assignable to type '() => ReadWriteStream'.
Type 'void' is not assignable to type 'ReadWriteStream'.
typings/globals/node/index.d.ts(2301,5): error TS2300: Duplicate
identifier 'export='.typings/globals/node/index.d.ts(2323,18): error
TS2300: Duplicate identifier 'Domain'.
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\ProgramFiles\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v4.4.4
npm ERR! npm v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! Angular2SampleProject2@1.0.0 start: `tsc && concurrently "tsc -w""lite
-server" `npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the Angular2SampleProject2@1.0.0 start script 'tsc &&
concurrently "tsc -w" "lite-server" '.
npm ERR! This is most likely a problem with the Angular2SampleProject2
包,npm 错误!不是 npm 本身。 npm 错误!告诉作者这在您的系统上失败: npm 错误! tsc && 同时 “tsc -w” “lite-server” npm 错误!您可以获得有关如何为此项目打开问题的信息 与:npm 错误! npm 错误 Angular2SampleProject2 npm 错误!或者,如果这不可用,您可以通过以下方式获取他们的信息: npm 错误! npm 错误! npm 所有者 ls Angular2SampleProject2 npm 错误!上面可能还有额外的日志输出。
npm 错误!请在任何支持请求中包含以下文件: npm 错误! C:\Users\kopuz\workspace\Angular2SampleProject2\npm-debug.log
【问题讨论】:
好像很模糊。我们需要更多细节来提供帮助。你能提供完整的错误信息吗? 您是否尝试将"exclude": ["node_modules"]
添加到您的tsconfig.json
?
你好 Diullei。我在我的问题中添加了错误消息。您可以在消息中看到它。应该有一些我错过的简单事情。
太好了,我还不清楚,但是您提供的详细信息越多,您获得帮助的机会就越多。看看@Saravana的这个问题
你好萨拉瓦娜。它说未知的编译器选项“排除”。我想我也必须编辑我的 package.json
【参考方案1】:
几天前我也遇到了同样的问题。 我通过以下方式修复了相同的问题:
将我的节点版本更新为7.7.2
更新到 package.json 中的 "@angular/compiler": "~2.4.9", "@angular/core": "~2.4.9"
这是我的 tsconfig 现在的样子:
"compilerOptions":
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"lib": [
"es6",
"dom"
]
,
"typeRoots": [
"node_modules/@types"
],
"types": [
"core-js",
"hammerjs"
],
"exclude": [
"node_modules"
]
【讨论】:
以上是关于npm 启动我的 Angular2 项目时出现重复的标识符导出错误的主要内容,如果未能解决你的问题,请参考以下文章
Angular 2:当我通过浏览器刷新时出现 404 错误[重复]
vue启动项目时出现的错误Error: Cannot find module 'D:\node_modules\npm\bin\npm-cli.js'
在我的反应 js 项目中运行 npm start 时出现白屏
使用 vue/cli 运行 npm run serve 时出现问题