Skip to content

Errors when running transform file from URL #316

@felipemsantana

Description

@felipemsantana

When I try to use a remote transform file it throws a lot of errors related to ES modules:

➜ npx jscodeshift -t 'https://raw.githubusercontent.com/reactjs/react-codemod/master/transforms/manual-bind-to-arrow.js' src/**/*.jsx
npx: instalou 276 em 10.734s
Processing 36 files...
Spawning 3 workers...
Sending 12 files to free worker...
Sending 12 files to free worker...
Sending 12 files to free worker...
/tmp/jscodeshift11939-8547-1x2kkqo.acev:24
export default function transformer(file, api) {
^^^^^^

SyntaxError: Unexpected token export
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Module._extensions..js (module.js:664:10)
    at Object.newLoader [as .js] (/home/fsantana/.npm/_npx/8547/lib/node_modules/jscodeshift/node_modules/pirates/lib/index.js:104:7)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
/tmp/jscodeshift11939-8547-1x2kkqo.acev:24

But saving the file locally and running:

npx jscodeshift -t manual-bind-to-arrow.js src/**/*.jsx

Works correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions