jashkenas / jashkenas/coffeescript

Bug: coffee command doesn't work with "type": "module" in package.json

Open
#5,362 3 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
CoffeeScript
Stars
16.6k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

Choose one: is this a bug report or feature request?
Bug report

### Input Code

```coffee
import {say} from './src/lib/coffee_utils.coffee'
say "Hello, World!"
```

### Expected Behavior

Outputs "Hello, World!" to the console

### Current Behavior

Error message:
(node:4316) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.

Now, that error is clearly coming from nodejs; however, I suspect that the real problem is with how the coffee command uses nodejs. The error message from nodejs is wholly unuseful because 1) it suggests doing something I've already done (put "type": "module" in my package.json) and 2) suggests doing something that isn't an option (my files are coffee files, so I can't use the .mjs extension). Maybe the coffee command can, however, let nodejs know that this is an ES module???

### Possible Solution

### Context

I use ES modules everywhere. But the coffee command can't run those files.

### Environment

* CoffeeScript version: 2.5.1
* Node.js version: 16.5.0

Contributor guide

Open the contributing guide

Research direction

Reproduce the supplied import example with package.json set to type: module, using CoffeeScript 2.5.1 and Node.js 16.5.0. Start at the coffee command entry point and trace how it invokes Node.js for CoffeeScript modules; done means the command runs the example and prints "Hello, World!" without the ES-module warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
coffeescript, node.js
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.