Skip to content

Node 12.13.1 - "require() of ES modules is not supported" from support-fetch-mock.js #481

Closed
@fruitraccoon

Description

@fruitraccoon

After updating node from version 12.13.0 to 12.13.1, I'm seeing the warning below when running npm ci:

> fetch-mock@8.0.1 postinstall C:\Users\jljob\projects\repos\work\vehicle-turnaround\ui\node_modules\fetch-mock
> node scripts/support-fetch-mock.js

(node:24100) Warning: require() of ES modules is not supported.
require() of C:\Users\jljob\projects\repos\work\vehicle-turnaround\ui\node_modules\fetch-mock\scripts\support-fetch-mock.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename support-fetch-mock.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\jljob\projects\repos\work\vehicle-turnaround\ui\node_modules\fetch-mock\package.json.

This is from this Node change. Unfortunately it is causing our build to fail on our CI server.

Reproduction steps:

  • Update node to version 12.13.1 (currently the latest LTS version)
  • In an empty folder run npm init and accept all default values
  • Run npm install fetch-mock

The warning above should be displayed.

Do any of the fixes suggested in the warning sound like they're a good fit for the project? (renaming the file to .cjs sounds the simplest to me)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions