akshayKhot akshayKhot - 1 month ago 28
TypeScript Question

Aurelia CLI + Typescript: Cannot find module errors

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).

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)


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'.


and so on..

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

Here is the
tsconfig.json
if that helps:

{
"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
}
}

Answer

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

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.

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

Comments