remark-cli "Cannot use import statement outside a module"

219 views Asked by At

I'm creating a documentation project which I npm init'd. This is the relevant part of my package.json

    "scripts": {
        "lint": "remark --quiet --frail ."
    },
    "type": "module",
    "dependencies": {
        "remark-cli": "^10.0.0",
        "remark-preset-lint-markdown-style-guide": "^5.0.0"
    },

I would now like to lint the Markdown files with remark-cli:

`remark --quiet --frail .`

This is the error I'm getting:

<...>/node_modules/remark-cli/cli.js:2
import {createRequire} from 'node:module'
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Module._compile (internal/modules/cjs/loader.js:895:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11

I thought adding "type": "module" to package.json would solve this but no luck.

What am I doing wrong here?

0

There are 0 answers