I need to import a package that has this configuration:
package.json
{
"name": "com.matheusdiasdesouzads.js.language-objects",
"main": "src/index.ts"
}
I'm importing this package from an outer package via:
my-outer-package/src/index.ts
import {Language} from 'com.matheusdiasdesouzads.js.language-objects';
Is it possible to keep my dependency configuration above as is and run ts-node src/index.ts
? I've a project similiarly structured that runs fine in ts-node
. Somehow my current project fails with this:
> ts-node src/index.ts # my-outer-package
< my-outer-package\node_modules\com.matheusdiasdesouzads.js.language-objects\src\index.ts:1
import Language, {Direction} from './language';
^^^^^^
SyntaxError: Cannot use import statement outside a module
Also note that running ts-node com.matheusdiasdesouzads.js.language-objects/src/index.ts
doesn't produce this module-related error.
Here are the full sources:
- language-objects
- message-locator (imports language-objects from NPM registry)
I tried everything in this question: Ts-node : SyntaxError: Cannot use import statement outside a module
- Set
compilerOptions.module
to"CommonJS"
. - Set
compilerOptions.target
to"ES2017"
. - Set
compilerOptions.esModuleInterop
totrue
. - Set
type
to"module"
in package.json.