Skip to content

Getting "Cannot use import statement outside a module" #1872

Description

@hydroper

Search Terms

There's a similiar issue, #922. However it is closed and the suggested solutions don't work for me.

Expected Behavior

No error.

Actual Behavior

I'm getting:

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

Steps to reproduce the problem

    1. git clone https://github.com/matheusdiasdesouzads/message-locator-js
    1. cd message-locator-js
    1. ts-node src/index.ts

Minimal reproduction

The repository https://github.com/matheusdiasdesouzads/message-locator-js is pretty short and only depends on https://github.com/matheusdiasdesouzads/language-objects-js, which is also short.

Specifications

  • ts-node version: v10.9.1
  • node version: v16.17.0
  • TypeScript version: v4.7.4
  • tsconfig.json, if you're using one:
{
  "compilerOptions": {
    "out": "dist/message-locator.js", 
    "sourceMap": true, 
    "target": "es6",
    "lib": ["es2015", "dom"],
    "noImplicitAny": true
  }
}
  • package.json:
{
  "name": "com.matheusdiasdesouzads.js.message-locator",
  "version": "1.0.0",
  "description": "",
  "main": "src/index.ts",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "matheusdiasdesouzads",
  "repository": "https://github.com/matheusdiasdesouzads/message-locator-js",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.27.2",
    "com.matheusdiasdesouzads.js.language-objects": "^1.1.0"
  }
}
  • Operating system and version: Windows 10 21H2 build 19044.1288
  • If Windows, are you using WSL or WSL2?:
    Windows 10, not WSL.

Activity

  1. locked and limited conversation to collaborators on Aug 26, 2022
  2. converted this issue into a discussion #1873 on Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions