petty-af icon indicating copy to clipboard operation
petty-af copied to clipboard

Errors when using *.js

Open devcybiko opened this issue 6 years ago • 2 comments

Seeing this when I petty-af *.js - possibly due to node version?

core$ node --version
v10.15.0
(node:64393) UnhandledPromiseRejectionWarning: SyntaxError: 'import' and 'export' may appear only with 'sourceType: "module"' (6:0)
    at Parser.raise (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:3834:17)
    at Parser.assertModuleNodeAllowed (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7332:12)
    at Parser.parseStatementContent (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7297:16)
    at Parser.parseStatement (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7199:17)
    at Parser.parseBlockOrModuleBlockBody (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7757:25)
    at Parser.parseBlockBody (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7744:10)
    at Parser.parseTopLevel (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7164:10)
    at Parser.parse (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:8565:17)
    at Object.parse (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:10537:38)
    at pettifyFile (/usr/local/lib/node_modules/petty-af/src/index.js:39:28)
(node:64393) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 11)
(node:64393) UnhandledPromiseRejectionWarning: SyntaxError: 'import' and 'export' may appear only with 'sourceType: "module"' (7:0)
    at Parser.raise (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:3834:17)
    at Parser.assertModuleNodeAllowed (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7332:12)
    at Parser.parseStatementContent (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7297:16)
    at Parser.parseStatement (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7199:17)
    at Parser.parseBlockOrModuleBlockBody (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7757:25)
    at Parser.parseBlockBody (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7744:10)
    at Parser.parseTopLevel (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:7164:10)
    at Parser.parse (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:8565:17)
    at Object.parse (/usr/local/lib/node_modules/petty-af/node_modules/@babel/parser/lib/index.js:10537:38)
    at pettifyFile (/usr/local/lib/node_modules/petty-af/src/index.js:39:28)
(node:64393) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 12)

devcybiko avatar Jan 24 '19 18:01 devcybiko

Works for me in node 10.15.0 on *.js.

I think that I saw this before when there was some error in my code (or just something the parser doesn't like), the parser wasn't able to get past it and make the AST I think. Is it ok to show me the file you ran it on? If it's a lot of files could you find one that causes it? If it's too much trouble that's totally ok, this is in no way worth a lot of trouble on your part.

Obviously I should be handling the error better even if the input code is irregular in some way.

hsubox76 avatar Jan 25 '19 22:01 hsubox76

Any file with import or export throws.

mohsen1 avatar Mar 11 '20 16:03 mohsen1