加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

AllowJS无法处理Angular

发布时间:2020-12-17 17:10:52 所属栏目:安全 来源:网络整理
导读:我的Angular项目中包含JS文件/库,它位于我的资源文件夹中.以前在角度4或2上,我没有在编译器选项中将AllowJS设置为true的问题,但是当我更新到Angular 5(CLI Typescript)时,它不起作用,它说 error TS5055: Cannot write file 'a path/afile.js' because it wou
我的Angular项目中包含JS文件/库,它位于我的资源文件夹中.以前在角度4或2上,我没有在编译器选项中将AllowJS设置为true的问题,但是当我更新到Angular 5(CLI Typescript)时,它不起作用,它说

error TS5055: Cannot write file '<a path/afile.js>' because it would overwrite input file.

仅包含allowJS(我的打字稿文件上没有导入)会在ng服务或ng构建时触发错误.
此外,删除它成功服务/构建我的项目,但我需要allowJS.

这是我的tsconfig.app.json

{
  "extends": "../tsconfig.json","compilerOptions": {
    "allowJs": true,"outDir": "../out-tsc/app","baseUrl": "./","module": "es2015","types": []

  },"exclude": [
    "test.ts","**/*.spec.ts"
  ]
}

这是我的角度版其他信息

Angular CLI: 1.5.4
Node: 8.9.1
OS: win32 x64
Angular: 5.0.0
... animations,common,compiler,compiler-cli,core,forms
... http,platform-browser,platform-browser-dynamic
... platform-server,router

@angular/cdk: 5.0.0-rc.1-6e865b7
@angular/cli: 1.5.4
@angular/language-service: 4.4.6
@angular/material: 5.0.0-rc.1-6e865b7
@angular-devkit/core: 0.0.21
@angular-devkit/schematics: 0.0.37
@schematics/angular: 0.1.7
typescript: 2.4.2
webpack: error

请帮助,因为其他solution和this不起作用.谢谢!

解决方法

我的工作正常

tsconfig.json

{
 "compileOnSave": false,"compilerOptions": {
 "declaration": false,"emitDecoratorMetadata": true,"experimentalDecorators": true,"module": "commonjs","moduleResolution": "node","outDir": "../dist/out-tsc-e2e","sourceMap": true,"target": "es5","allowJs": true,"typeRoots": [
   "../node_modules/@types"
 ]
}}

角度版本:

/    _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
 / △  | '_  / _` | | | | |/ _` | '__|   | |   | |    | |
/ ___ | | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   __| |_|__,|__,_|_|__,_|_|       ____|_____|___|
              |___/

Angular CLI: 1.6.0
Node: 9.3.0
OS: linux x64
Angular: 5.1.3
... animations,language-service,platform-browser
... platform-browser-dynamic,router

@angular/cli: 1.6.0
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读