【问题标题】:NativeScript Angular Error TS5060: Option 'paths' cannot be used without specifying '--baseUrl' optionNativeScript Angular 错误 TS5060:如果不指定“--baseUrl”选项,则无法使用选项“路径”
【发布时间】:2020-11-05 05:29:19
【问题描述】:

我刚刚安装了 Nativescript Angular 项目,使用:

ng new --collection=@nativescript/schematics my-mobile-app

我从nativescript-schematics得到的命令

在全新安装后,我尝试在 android 模拟器上运行它。

tns run android

然后我在编译过程中收到此错误:

Searching for devices...
Preparing project...
File change detected. Starting incremental webpack compilation...

webpack is watching the files…

Hash: c018afa003f9a5a7d1cd
Version: webpack 4.44.2
Time: 4451ms
Built at: 11/05/2020 1:54:33 PM
 3 assets
Entrypoint bundle = runtime.js vendor.js bundle.js
[./app.css] 1.05 KiB {bundle} [built]
[./main.ts] 1.13 KiB {bundle} [built]
[~/package.json] external "~/package.json" 42 bytes {bundle} [optional] [built]
    + 331 hidden modules

ERROR in error TS5060: Option 'paths' cannot be used without specifying '--baseUrl' option.

【问题讨论】:

    标签: angular webpack nativescript angular2-nativescript nativescript-angular


    【解决方案1】:

    我也遇到了同样的错误。我修复它的方法是将"baseUrl": ".", 添加到 tsconfig.json

    所以你的 tsconfig.json 最终看起来像:

    {
      "compilerOptions": {
        "module": "ESNext",
        "target": "es2017",
        "moduleResolution": "node",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "skipLibCheck": true,
        "noEmitHelpers": true,
        "noEmitOnError": true,
        "baseUrl": ".",          // add this line
        "lib": [
          "es2017",
          "dom",
          "es6"
        ]
      },
      "exclude": [
        "node_modules",
        "platforms"
      ]
    }
    

    但是你可能会遇到的下一个错误是:

    cp: no such file or directory: E:/NativeScript/my-app/App_Resources/Android/*
    

    为了解决这个问题,我将 app 文件夹中的 App_Resources 文件夹上移了一级,例如:

    • 来自my-app/app/App_Resources
    • my-app/App_Resources

    然后它终于正确运行了!

    【讨论】:

      猜你喜欢
      • 2017-06-21
      • 2022-06-16
      • 1970-01-01
      • 2014-05-17
      • 2020-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多