Can't import the other TypeScript file

Can’t import the other TypeScript file.

I encountered an error when I import a TypeScript file to the other TypeScript file. Please tell me the way to fix it. In following explanation, using this repository.

Steps to reproduce

My environments:

  • Cocos Creator: v2.1.3
  • OS X: v10.14.3
  • Google Chrome: v77.0.3865.120
  1. Make a TypeScript HelloWorld Project.
  2. Make a small TypeScript class doing something.
  3. Imports TypeScript class made in step 2 to HelloWorld.ts .
  4. Run this game in preview mode and then you can see that this game run as expected.
  5. But this game broken when you build in debug/release mode otherwise build options. You can see following error at browser console:

error1

your sample runs fine in CC 2.0.10, both in preview and debug/release builds. what typescript version do you have installed?

you can try to import the class like below, see if it makes any difference.

import {Plus} from './Plus';

I’m using typescript v3.6.4 .

$ tsc -v
Version 3.6.4

So, I think Cocos Creator should use v3.6.4 typescript in my environment, but I don’t know whether Cocos Creator really use this version.

I will try to build this app while downing typescript version.

PS:
I built and tried to fix in v3.0 v2.9.2 v2.8.4 , but this error didn’t fix.

I resolved this problem.
You can fix this error by restarting nodejs.

Kill node.js processes:

$ kill -9 $(ps -e | grep node | awk '{print $1}')

and then, run cocos creator.