dvdciri / daggraph

Dagger dependency graph generator for Android Developers
MIT License
1.15k stars 58 forks source link

Error "SyntaxError: Unexpected token function" #31

Closed gorgeorg closed 6 years ago

gorgeorg commented 6 years ago

Description

There is error when run daggraph in Android project folder.

Steps to reproduce

E:\>daggraph C:\Users\\AppData\Roaming\npm\node_modules\daggraph\src\dagger\DaggerAnalyzer.js:13 async function findComponents(projectRootPath){ ^^^^^^^^ SyntaxError: Unexpected token function at Object.exports.runInThisContext (vm.js:76:16) at Module._compile (module.js:542:28) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (C:\Users\\AppData\Roaming\npm\node_modules\daggraph\src\router.js:7:25) at Module._compile (module.js:570:32)

Expected behaviour

Created dependency graph

Screenshot

mozarty commented 6 years ago

same here

dvdciri commented 6 years ago

Thanks for reporting that, do you have a sample project on github that I can test and reproduce this?

dvdciri commented 6 years ago

Can you also try to upgrade node to the latest version and check the version that you have. Some versions does not support the async function

gorgeorg commented 6 years ago

Hi. I have updated node to v8.9.4. The result is: E:\>daggraph Analyzing dagger components and modules.. TypeError: pending.then is not a function at FileHound._searchAsync (C:\Users\Name\AppData\Roaming\npm\node_modules\daggraph\node_modules\filehound\lib\filehound.js:705:22) at tryCatcher (C:\Users\Name\AppData\Roaming\npm\node_modules\daggraph\node_modules\bluebird\js\release\util.js:16:23) at MappingPromiseArray._promiseFulfilled (C:\Users\Name\AppData\Roaming\npm\node_modules\daggraph\node_modules\bluebird\js\release\map.js:61:38) at MappingPromiseArray.PromiseArray._iterate (C:\Users\Name\AppData\Roaming\npm\node_modules\daggraph\node_modules\bluebird\js\release\promise_array.js:114:31) at MappingPromiseArray.init (C:\Users\Name\AppData\Roaming\npm\node_modules\daggraph\node_modules\bluebird\js\release\promise_array.js:78:10) at MappingPromiseArray._asyncInit (C:\Users\Name\AppData\Roaming\npm\node_modules\daggraph\node_modules\bluebird\js\release\map.js:30:10) at Async._drainQueue (C:\Users\Name\AppData\Roaming\npm\node_modules\daggraph\node_modules\bluebird\js\release\async.js:138:12) at Async._drainQueues (C:\Users\Name\AppData\Roaming\npm\node_modules\daggraph\node_modules\bluebird\js\release\async.js:143:10) at Immediate.Async.drainQueues (C:\Users\Name\AppData\Roaming\npm\node_modules\daggraph\node_modules\bluebird\js\release\async.js:17:14) at runCallback (timers.js:789:20) at tryOnImmediate (timers.js:751:5) at processImmediate [as _immediateCallback] (timers.js:722:5)

dvdciri commented 6 years ago

What version of Daggraph are you using? Try updating the latest one..

gorgeorg commented 6 years ago

"version": "0.2.5", from package.json. Also I have downloaded https://github.com/dvdciri/MVP-Clean-Sample-Android. Result the same as I mentioned above.

mibrahimdev commented 6 years ago

same error with me too

` /usr/lib/node_modules/daggraph/src/dagger/DaggerAnalyzer.js:13 async function findComponents(projectRootPath){ ^^^^^^^^ SyntaxError: Unexpected token function at Object.exports.runInThisContext (vm.js:76:16) at Module._compile (module.js:513:28) at Object.Module._extensions..js (module.js:550:10) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at Object. (/usr/lib/node_modules/daggraph/src/router.js:7:25) at Module._compile (module.js:541:32)

`

Edit: after updating npm the works fine now.

iamBedant commented 6 years ago

Getting the same error after updating to V0.2.5. Before updating It was working as expected

dvdciri commented 6 years ago

@gorgeorg The project you mentioned doesn't use dagger and i'm correctly getting this:

➜  MVP-Clean-Sample git:(master) ✗ daggraph
Analyzing dagger components and modules..
Couldn't find any components, are you sure this project is using Dagger?

Is someone else is still having this issue, try to update npm to the latest version as mentioned by @MohamedISoliman. Please let me know if you manage to fix this, so i can close.

gorgeorg commented 6 years ago

Sorry my fault about MVP-Clean-Sample. Could you try on https://github.com/mgrzechocinski/dagger2-example?

dvdciri commented 6 years ago

@gorgeorg The only issue i'm having with that repo is that the build folder does not exists, so when it asks me to generate a the chart i want, it fails. Will fix that very soon.

If i create manually the folder the chart is generated succesfully. Node: v9.2.1 Npm: 5.5.1 Daggraph: 0.2.5

The bug has been fixed here #35

dvdciri commented 6 years ago

Closing due to lack of activity.