Git Product home page Git Product logo

Comments (7)

henryruhs avatar henryruhs commented on May 29, 2024 51

@jordansexton Thank you so much, that worked for me!

package.json

{
	"type": "module"
}

tsconfig.json

{
	"compilerOptions": {
		"module": "esnext",
		"moduleResolution": "node",
	}
}

.mocharc.json

{
	"node-option": [
		"experimental-specifier-resolution=node",
		"loader=ts-node/esm"
	]
}

from mocha-examples.

jordaaash avatar jordaaash commented on May 29, 2024 14

FWIW, here's a configuration for Mocha, TypeScript, and ESM that finally worked for me:
https://gist.github.com/jordansexton/2a0c3c360aa700cc9528e89620e82c3d

"node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm"] was the clincher.

from mocha-examples.

fcamblor avatar fcamblor commented on May 29, 2024 7

Thanks to all of you here, it helped me a lot :-)

I would simply add that one requirement is to use mocha@9 ([email protected] for me) as I was on mocha@8 and I was getting following error :

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

from mocha-examples.

cspotcode avatar cspotcode commented on May 29, 2024

Thanks. Time permitting I'll send a pull request with a sample. Till then, I'm subscribed to this thread and can answer questions.

from mocha-examples.

Dunky13 avatar Dunky13 commented on May 29, 2024

I'm looking for a solution on this as well

from mocha-examples.

FauxFaux avatar FauxFaux commented on May 29, 2024

Hi everyone else from search results.

This only works on node 16, haven't been able to get it to work on 18 or 20.

Newer nodes don't like, and don't need(?) the "experimental-specifier-resolution=node",

from mocha-examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.