ember-native-class-codemod icon indicating copy to clipboard operation
ember-native-class-codemod copied to clipboard

TypeError: Cannot read property 'from' of undefined

Open sarbbottam opened this issue 5 years ago • 7 comments

/usr/local/lib/node_modules/ember-native-class-codemod/node_modules/@babel/core/lib/transformation/index.js:66
    throw e;
    ^
TypeError: /usr/local/lib/node_modules/ember-native-class-codemod/node_modules/safe-buffer/index.js: Cannot read property 'from' of undefined
    at Converter.toBase64 (/usr/local/lib/node_modules/ember-native-class-codemod/node_modules/convert-source-map/index.js:61:28)
    at Converter.toComment (/usr/local/lib/node_modules/ember-native-class-codemod/node_modules/convert-source-map/index.js:65:21)
    at generateCode (/usr/local/lib/node_modules/ember-native-class-codemod/node_modules/@babel/core/lib/transformation/file/generate.js:78:76)
    at run (/usr/local/lib/node_modules/ember-native-class-codemod/node_modules/@babel/core/lib/transformation/index.js:55:33)
    at run.next (<anonymous>)
    at Function.transform (/usr/local/lib/node_modules/ember-native-class-codemod/node_modules/@babel/core/lib/transform.js:27:41)
    at transform.next (<anonymous>)
    at evaluateSync (/usr/local/lib/node_modules/ember-native-class-codemod/node_modules/gensync/index.js:244:28)
    at Function.sync (/usr/local/lib/node_modules/ember-native-class-codemod/node_modules/gensync/index.js:84:14)
    at Object.transform (/usr/local/lib/node_modules/ember-native-class-codemod/node_modules/@babel/core/lib/transform.js:36:54) {
  code: 'BABEL_GENERATE_ERROR'
}

sarbbottam avatar Jun 08 '20 14:06 sarbbottam

This is strange, I uninstalled the global ember-native-class-codemod and ran with npx, it worked fine.

sarbbottam avatar Jun 08 '20 14:06 sarbbottam

In general, I would not advise running globally. Using npx will make sure to get you the latest every time...

rwjblue avatar Jun 08 '20 14:06 rwjblue

I am running the code mod on a smaller subset of files. Since this codemod needs to install chromium, every npx execution is taking substantially longer.

Also, I installed the codemod globally just a few minutes prior to the npx run.

sarbbottam avatar Jun 08 '20 15:06 sarbbottam

I'm seeing the same error, running as npx ember-native-class-codemod http://localhost:4200 app/controllers/*.js

ballPointPenguin avatar Jul 24 '20 15:07 ballPointPenguin

Similarly I installed a fresh node version with nvm (12.18.3) and ran again with npx and it works! It does seem like clearing the global modules may be the reason it's working for me.

ballPointPenguin avatar Jul 27 '20 16:07 ballPointPenguin

Is there a reason this won't work when running globally?

gabrielcsapo avatar Jan 15 '21 22:01 gabrielcsapo

Is there a reason this won't work when running globally?

No, but there are combinations of conflicting versions that folks hit which is not an issue when using npx (vs a permanent global install). I think volta install would also probably work just fine, but haven't tried it.

rwjblue avatar Jan 15 '21 22:01 rwjblue