【问题标题】:Angular Cli update changed the location where my app looks for node_modules. How do I change it back?Angular Cli 更新更改了我的应用程序查找 node_modules 的位置。我该如何改回来?
【发布时间】:2018-02-24 07:41:33
【问题描述】:

版本。

@angular/cli: 1.4.2
node: 6.10.0
os: linux x64
@angular/animations: 4.3.6
@angular/common: 4.3.6
@angular/compiler: 4.3.6
@angular/compiler-cli: 4.3.6
@angular/core: 4.3.6
@angular/forms: 4.3.6
@angular/http: 4.3.6
@angular/platform-browser: 4.3.6
@angular/platform-browser-dynamic: 4.3.6
@angular/platform-server: 4.3.6
@angular/router: 4.3.6
@angular/cli: 1.4.2
typescript: 2.5.2

在我更新到最新版本的 angular-cli 后开始出现此错误

失败给出的日志。

client?ffdb:119 ./~/script-loader/addScript.js
Module build failed: Error: ENOENT: no such file or directory, open             '/usr/src/app/angular/node_modules/script-loader/addScript.js'
 @ ./~/script-loader!./~/jquery/dist/jquery.min.js 1:0-73
 @ multi script-loader!./~/jquery/dist/jquery.min.js script-    loader!./~/froala-editor/js/froala_editor.pkgd.min.js

所需的功能。

此错误会阻止我的应用程序编译。出于某种原因,angular 现在正在 usr/src/app/angular 中查找 node_modules 文件夹,而它之前没有在此处查找(它不存在)。此外,它突然在寻找一个脚本加载器模块,该模块在 angular-cli 更新之前并不存在。

我的 Angular-cli.json 文件如下所示:

{
  "project": {
    "version": "1.0.0-beta.28.3",
    "name": "angular-client"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
  "assets": [
    "assets",
    "favicon.ico"
  ],
  "addons": [
    "../node_modules/font-awesome/fonts/*.+(otf|eot|svg|ttf|woff|woff2)"
  ],
  "index": "index.html",
  "main": "main.ts",
  "polyfills": "polyfills.ts",
  "test": "test.ts",
  "tsconfig": "tsconfig.json",
  "prefix": "app",
  "styles": [
    "styles.css",
    "../node_modules/font-awesome/css/font-awesome.css",
    "../node_modules/froala-editor/css/froala_editor.pkgd.min.css"
  ],
  "scripts": [
    "../node_modules/jquery/dist/jquery.min.js",
    "../node_modules/froala-editor/js/froala_editor.pkgd.min.js"
  ],
  "environmentSource": "environments/environment.ts",
    "environments": {
    "dev": "environments/environment.ts",
    "prod": "environments/environment.prod.ts"
    }
    }
  ],
  "e2e": {
"protractor": {
  "config": "./protractor.conf.js"
}
  },
  "lint": [
    {
  "files": "src/**/*.ts",
  "project": "src/tsconfig.json"
},
{
  "files": "e2e/**/*.ts",
  "project": "e2e/tsconfig.json"
    }
 ],
  "test": {
"karma": {
  "config": "./karma.conf.js"
    }
  },
  "defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"inline": {
  "style": false,
  "template": false
},
"spec": {
  "class": false,
  "component": true,
  "directive": true,
  "module": false,
  "pipe": true,
  "service": true
    }
  }
}

我的 tsconfig.app.json 文件如下所示:

{
 "compilerOptions": {
    "baseUrl": "",
    "declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
  "../node_modules/@types"
    ]
  }
}

【问题讨论】:

    标签: angular angular-cli


    【解决方案1】:

    原来我不得不重新启动 Docker 容器。现在可以了。

    【讨论】:

      猜你喜欢
      • 2014-05-08
      • 1970-01-01
      • 2013-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-07
      • 1970-01-01
      相关资源
      最近更新 更多