Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" #152

Open
FreePhoenix888 opened this issue Jan 13, 2023 · 1 comment

Comments

@FreePhoenix888
Copy link

FreePhoenix888 commented Jan 13, 2023

Minimal reproduction example:

gulpfile.ts:

import * as gulp from 'gulp';
import {deleteAsync} from 'del';

gulp.task('a', async () => {
  console.log("a result");
  await deleteAsync(["notExistingFile.txt"]);
});

package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/gulp": "^4.0.10",
    "gulp": "^4.0.2",
    "del": "7.0.0",
    "ts-node": "^10.9.1",
    "typescript": "^4.9.4"
  }
}

Solution

Install 6.1.1 version and use old api accordingly:

import del from 'del';
await del(paths);
@Bukunmikuti
Copy link

Same behaviour with rollup.config.ts. Downgrading to version 6.1.1 and using del() rather than deleteAsync() fixed it.

// custom rollup plugin
import { deleteAsync } from 'del'

const myDel = () => {
   return {
      name: 'types-delete',
      buildEnd: async () => {
          const d = await deleteAsync(['dist/types'])
          console.log(d.length)
      }
}

[!] Error: While loading the Rollup configuration from "rollup.config.ts", Node tried to require an ES module from a CommonJS file, which is
not supported. A common cause is if there is a package.json file with "type": "module" in the same folder. You can try to fix this by changing the extension of your configuration file to ".cjs" or ".mjs" depending on the content, which will prevent Rollup from trying to preprocess
the file but rather hand it to Node directly.

beatonma added a commit to beatonma/beatonma.org that referenced this issue Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants