E / launcher - 错误:TSError:无法编译Typescript

时间:2017-06-06 22:27:53

标签: node.js typescript ts-node

嘿伙计们,我正面临以下问题:

我的项目是建立在Angular4上的打字稿,e2e测试用量角器&业。但是几天后我不断收到以下错误:

File 'D:/myproject/node_modules/protractor/package.json' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. (
6054)
File 'D:/myproject/node_modules/q/package.json' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. (6054)
File 'D:/myproject/node_modules/selenium-webdriver/package.json' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.
d.ts'. (6054)
File 'D:/myproject/node_modules/source-map/package.json' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. (
6054)
File 'D:/myproject/node_modules/tapable/package.json' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. (605
4)
File 'D:/myproject/node_modules/tslib/package.json' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. (6054)

File 'D:/myproject/node_modules/uglify-js/package.json' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. (6
054)
File 'D:/myproject/node_modules/webdriver-js-extender/node_modules/selenium-webdriver/package.json' has unsupported extension. The only support
ed extensions are '.ts', '.tsx', '.d.ts'. (6054)
File 'D:/myproject/node_modules/webdriver-js-extender/package.json' has unsupported extension. The only supported extensions are '.ts', '.tsx',
 '.d.ts'. (6054)
    at getOutput (D:\myproject\node_modules\ts-node\src\index.ts:300:15)
    at D:\myproject\node_modules\ts-node\src\index.ts:330:16
    at Object.compile (D:\myproject\node_modules\ts-node\src\index.ts:489:17)
    at Module.m._compile (D:\myproject\node_modules\ts-node\src\index.ts:382:43)
    at Module._extensions..js (module.js:580:10)
    at Object.require.extensions.(anonymous function) [as .ts] (D:\myproject\node_modules\ts-node\src\index.ts:385:12)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
[23:41:57] E/launcher - Process exited with error code 100

据我了解错误消息,typscript加载程序尝试转换非ts文件。在发布我的问题之前,我确实搜索了整个互联网,看起来我的tsconfig.json内的@types无法正常工作。

我已经检查了@types和tsconfig的文档以及github上的相关问题,但我认为它在这里行为不正确。文件声明,

  

仅包含支持扩展名的文件(例如.ts,.tsx和   .d.ts默认情况下使用.js和.jsx,如果allowJs设置为true)。

那为什么要尝试包含所有.json文件?

  

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "noEmit": true,
    "noEmitHelpers": true,
    "importHelpers": true,
    "strictNullChecks": false,
    "lib": [
      "dom",
      "es6"
    ],
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": [
      "hammerjs",
      "jasmine",
      "node",
      "source-map",
      "uglify-js",
      "webpack"
    ]
  },
  "exclude": [
    "node_modules",
    "dist"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

有关myproject的详细信息:

  

node v7.4.0

     

npm v4.1.2

     

typescript@2.3.4

     

protractor@5.1.2

├── src/
│   ├── custom-typings.d.ts
├── node_modules/
│   ├── @types
│   |   ├── hammerjs
│   |   |   ├── index.d.ts
│   |   |   ├── package.json
│   |   |   ├── README.md
│   |   |   ├── types-metadata.json
│   |   ├── jasmine
│   |   |   ├── index.d.ts
│   |   |   ├── ...
│   |   ├── node
│   |   |   ├── index.d.ts
│   |   |   ├── ...
│   |   ├── source-map
│   |   |   ├── index.d.ts
│   |   |   ├── ...
│   |   ├── uglify-js
│   |   |   ├── index.d.ts
│   |   |   ├── ...
│   |   ├── webpack
│   |   |   ├── index.d.ts
│   |   |   ├── ...
│   |   ├── ...
│   └── (@agm, @angular, ...)
└── package.json

我已尝试过的内容:

  • 删除排除块,因为它包含与默认值相同的内容:
  

"排除" property默认为在未指定时排除node_modules,bower_components,jspm_packages和目录。

  • 设置选项" allowJs:true",导致缺少文件加载器(不是合适的解决方案)

  • 删除typeRoots以使用默认设置,导致相同的错误

如何解决此问题,只加载适当的.ts文件? 在此先感谢您的帮助!

  • 添加"include": [ "src/**/*" ]"include": [ "src/**/*.ts" ] - 导致同样的错误

其他资源:

0 个答案:

没有答案