Friday, 14 April 2017

create-react-app and JavaScript dependency that is using async/await fails to compile

Steps to reproduce:

npm install -g create-react-app
create-react-app demo-app
cd demo-app
npm install --save instascan
# add `import Instascan from 'instascan'` to index.js
npm start

Error message:

Failed to compile.

Error in ./~/instascan/src/camera.js
Module parse failed: /Users/rd/code/instascan-react/node_modules/instascan/src/camera.js Unexpected token (13:8)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (13:8)
 @ ./~/instascan/index.js 6:10-33

Error in ./~/instascan/src/scanner.js
Module parse failed: /Users/rd/code/instascan-react/node_modules/instascan/src/scanner.js Unexpected token (208:8)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (208:8)
 @ ./~/instascan/index.js 5:11-35

Further inspection show that calls to async are found at camera.js:13 and scanner.js:208. The create-react-app docs say that async/await is supported, but maybe this isn't enabled for dependencies?

I'm not sure what to try next. Any guidance here would be much appreciated.



via Richard

No comments:

Post a Comment