Aurelia CLI + Typescript:找不到模块错误 [英] Aurelia CLI + Typescript: Cannot find module errors

查看:60
本文介绍了Aurelia CLI + Typescript:找不到模块错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据Aurelia主页此处上的视频教程建立一个基本的Aurelia项目.我想我已经按照视频中给出的确切步骤进行了操作(只是将ES6更改为Typescript).

I am trying to set up a basic Aurelia project following the video tutorial on Aurelia Homepage here. I think I have followed the exact steps given in the video (just changed ES6 to Typescript).

当我尝试通过执行au run --watch来运行应用程序时,它给了我这个错误:

When I tried to run the app by executing au run --watch, it gave me this error:

ReferenceError: define is not defined
at Object.<anonymous> (/aurelia_project/tasks/build.js:1:63)

进一步调查,当我打开aurelia_project目录时,我发现所有.ts文件都充满了cannot find module错误.例如,

Investigating further, when I opened aurelia_project directory, I found that all the .ts files are filled with cannot find module errors. For example,

[ts] Cannot find module 'gulp'.
[ts] Cannot find module 'aurelia-cli'.

以此类推.

我是否必须执行其他步骤才能解析这些模块?

Do I have to execute some additional step for typescript cli ot resolve these modules?

如果有帮助,请点击tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "sourceMap": true,
    "target": "es5",
    "module": "amd",
    "declaration": false,
    "noImplicitAny": false,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "lib": ["es2015", "dom"]
  },
  "exclude": [
    "node_modules",
    "aurelia_project"
  ],
  "filesGlob": [
    "./src/**/*.ts",
    "./test/**/*.ts",
    "./typings/index.d.ts",
    "./custom_typings/**/*.d.ts"
  ],
  "atom": {
    "rewriteTsconfig": false
  }
}

推荐答案

删除aurelia_json/tasks中的所有*.js文件.然后重复au run --watch.

Delete all the *.js files inside aurelia_json/tasks. Then repeat au run --watch.

为什么?您错误地将aurelia_json/tasks TypeScript编译为JavaScript,这是您不希望这样做的,因为Aurelia CLI使用gulp-typescript.删除aurelia_json/tasks中的所有*.js文件,就可以了.

Why? You have mistakenly transpiled your aurelia_json/tasks TypeScript into JavaScript, which you do not want to do, because the Aurelia CLI uses gulp-typescript. Delete all the *.js files inside aurelia_json/tasks and you will be fine.

该问题与类型定义无关.正如Meirion Hughes所说,TypeScript编译器在没有它们的情况下可以工作.

The problem is unrelated to type definitions. As Meirion Hughes commented, the TypeScript compiler works without them.

这篇关于Aurelia CLI + Typescript:找不到模块错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆