首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >缺少*.ts文件(由于‘`npm链接’?)

缺少*.ts文件(由于‘`npm链接’?)
EN

Stack Overflow用户
提问于 2018-02-14 22:15:43
回答 4查看 28.9K关注 0票数 14

我在一个Angular5项目中有一个导入语句:

代码语言:javascript
复制
import {plugins, SCECodeGenType} from 'sce-plugins/code-generation';

这将解决我的文件系统上的这个路径:

代码语言:javascript
复制
/Users/.../suman-chrome-extension/node_modules/sce-plugins/code-generation/index.d.ts

在使用ng build -w构建应用程序时,我会得到以下错误:

代码语言:javascript
复制
ERROR in ../sce-plugins/code-generation/index.ts Module build failed: Error: /Users/alexamil/WebstormProjects/oresoftware/sumanjs/sce-plugins/code-generation/index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-chrome-extension/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:662:23)
    at plugin.done.then (/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-chrome-extension/node_modules/@ngtools/webpack/src/loader.js:467:39)
    at <anonymous>  @ ./src/app/shared/services/lang.service.ts 14:24-62  @ ./src/app/app.module.ts  @ ./src/main.ts  @ multi ./src/main.ts

我相信这是因为我正在使用npm link链接'sce-plugins'项目以进行本地开发。

我在这里看到了将npm link与Angular5项目结合使用的一些问题:

https://github.com/angular/angular-cli/issues/3875

https://github.com/angular/angular-cli/issues/8677

https://github.com/angular/angular-cli/issues/9376

有人知道怎么修吗?

更新:

它似乎不适用于npm link perse或符号链接。如果我简单地将本地目录复制到node_modules/sce-plugins,就会得到同样的错误。然而,如果我npm install sce插件到node_modules,那么我就不会得到错误。很奇怪,好像是角质层,而不是NPM。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2018-02-15 00:24:44

因此,在再次阅读了这个Github问题之后:https://github.com/angular/angular-cli/issues/8284

我在.angular-cli.json中做了这个改变

代码语言:javascript
复制
  "defaults": {
    "build": {
      "preserveSymlinks": true //   <<<< add this
    },
    "styleExt": "scss",
    "component": {
    }
  }

现在,考虑到preserveSymlinks标志和我的tsconfig.app.json文件中的include字段:

代码语言:javascript
复制
 "include":[
    "./**/*.ts",
    "../node_modules/sce-plugins/**/*.ts"
  ],

我现在可以将'sce-plugins'符号链接到我的主项目中,而不是手动复制文件。您可能根本不需要"include"字段,尽管我发现如果删除"include"字段,它将无法工作。

票数 37
EN

Stack Overflow用户

发布于 2018-09-07 14:24:34

在角6 "angular.json“文件中,需要将"preserveSymlinks”放在“选项”下面:

代码语言:javascript
复制
"defaults": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "preserveSymlinks": true,
            "outputPath": "dist/ConsoleClient",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/web.config"
            ],
票数 13
EN

Stack Overflow用户

发布于 2020-01-27 17:10:25

在将我的应用程序从角5迁移到6时,我遇到了同样的问题,修复了我已经应用的程序:

includes array of tsconfig.app.json中添加了缺失文件的条目(注意:文件名不是tsconfig.json)

另外,请确保您所提到的丢失文件的路径相对于tsconfig.app.json

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48797135

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档