gpt4 book ai didi

npm - Angular 2 beta "npm run tsc"命令失败

转载 作者:太空狗 更新时间:2023-10-29 18:34:49 28 4
gpt4 key购买 nike

我似乎无法使用 npm run ts"命令编译我的 Typescript。我觉得有点奇怪的是我可以运行 npm start 并且它可以正常编译和运行。

日志如下:

0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'run', 'tsc' ]
2 info using npm@2.11.3
3 info using node@v0.12.7
4 verbose run-script [ 'pretsc', 'tsc', 'posttsc' ]
5 info pretsc MyProject@1.0.0
6 info tsc MyProject@1.0.0
7 verbose unsafe-perm in lifecycle true
8 info MyProject@1.0.0 Failed to exec tsc script
9 verbose stack Error: MyProject@1.0.0 tsc: `tsc`
9 verbose stack Exit status 2
9 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
9 verbose stack at EventEmitter.emit (events.js:110:17)
9 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
9 verbose stack at ChildProcess.emit (events.js:110:17)
9 verbose stack at maybeClose (child_process.js:1015:16)
9 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
10 verbose pkgid MyProject@1.0.0
11 verbose cwd /Users/kasperlaursen/adnexio.frontend
12 error Darwin 15.3.0
13 error argv "node" "/usr/local/bin/npm" "run" "tsc"
14 error node v0.12.7
15 error npm v2.11.3
16 error code ELIFECYCLE
17 error MyProject@1.0.0 tsc: `tsc`
17 error Exit status 2
18 error Failed at the MyProject@1.0.0 tsc script 'tsc'.
18 error This is most likely a problem with the MyProject package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error tsc
18 error You can get their info via:
18 error npm owner ls MyProject
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

tsconfig.json:

{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "./bin"
},
"exclude": [
"node_modules"
]
}

包.JSON:

{
"name": "MyProject",
"version": "1.0.0",
"scripts": {
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
},
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-beta.3",
"systemjs": "0.19.6",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.11"
},
"devDependencies": {
"concurrently": "^1.0.0",
"lite-server": "^2.0.1",
"typescript": "^1.7.5"
}
}

最佳答案

您可能使用“npm install”安装您的依赖项。这意味着它们不在路径中。这就是为什么直接使用 tsc 命令不起作用的原因。

当使用“npm run start”时,我怀疑并发对路径做了一些事情,以便能够使用 node_modules 文件夹中的 libraires(及其 tsc 命令)。

像“$(npm bin)”这样的用法:

> $(npm bin)/tsc

有关详细信息,请参阅此问题:

这篇文章也可能让您感兴趣:

关于npm - Angular 2 beta "npm run tsc"命令失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35726008/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com