[英]typescript tsc error TS2307: Cannot find module '@angular/core'
I am trying to build a typescript project with jenkins. 我正在尝试使用jenkins构建一个打字稿项目。 But when i run tsc I get errors regarding non-relative imports from typescript files.
但是,当我运行tsc时,我从打字稿文件中得到了非相对导入的错误。
Here is a excerpt from the build. 这是该版本的摘录。
+ ls node_modules/@angular/
common
compiler
core
http
platform-browser
platform-browser-dynamic
router
router-deprecated
+ tsc
client/dev/marvel-app/app.component.ts(2,25): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/app.component.ts(3,9): error TS2305: Module '"/root/.jenkins/jobs/marvel-encyclopedia/workspace/node_modules/@angular/router-deprecated/index"' has no exported member 'RouteConfig'.
client/dev/marvel-app/helpers/parallax.directive.ts(8,17): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/filter/filter.component.ts(1,51): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/go-back-up/go-back-up.component.ts(1,25): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/graph/graph.component.ts(1,100): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/grid/grid.component.ts(1,62): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/header/header.component.ts(1,25): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/navbar/navbar.component.ts(1,25): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/search/search.component.ts(1,51): error TS2307: Cannot find module '@angular/core'.
client/dev/marvel-app/modules/search/search.component.ts(2,23): error TS2307: Cannot find module '@angular/common'.
here is the content of my tsconfig.json file: 这是我的tsconfig.json文件的内容:
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings",
"typings/main",
"typings/main.d.ts"
],
"filesGlob": [
"**/*.ts",
"typings/main",
"typings/main.d.ts"
]
}
I tried locally on my mac and it works fine. 我在Mac上在本地尝试过,效果很好。 Jenkins is located on a linux machine.
Jenkins位于Linux机器上。
EDIT : Actually the error came from a bad installation of the node modules. 编辑 :实际上,该错误来自错误的节点模块安装。 deleting
node_modules
and re-installing fix that problem. 删除
node_modules
并重新安装node_modules
该问题。
You have tsconfig like the following: 您的tsconfig如下所示:
"exclude": [
"node_modules",
"typings",
"typings/main",
"typings/main.d.ts"
],
"filesGlob": [
"**/*.ts",
"typings/main",
"typings/main.d.ts"
]
Most likely filesGlob
isn't support in your build process and exclude
is kicking in. You are excluding typings/main
(which are including in filesGlob and hence it works locally) 最有可能在您的构建过程中不支持
filesGlob
,并且exclude
。您正在排除类型typings/main
(它们包含在filesGlob中,因此可以在本地工作)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.