koltyakov / node-sp-auth-config

🔧 Config options builder for node-sp-auth (SharePoint Authentication in Node.js)
MIT License
20 stars 11 forks source link

Syntax Error: Unexpected Token siteUrl.js your use of Inquirer.js Prompt #9

Open bhalfacre opened 6 years ago

bhalfacre commented 6 years ago

This error was bubbling up from use with node-sp-auth, spsave, and gulp-spsave

nodemodules\inquirer\lib\prompts\list.js:32 let index = .findIndex(this.opt.choices.realChoices, ({ value }) => value === def); ^ SyntaxError: Unexpected token { at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:404:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Function.promptModule.restoreDefaultPrompts (myPath\node_modules\inquirer\lib\inquirer.js:55:33) at Object.inquirer.createPromptModule (myPath\node_modules\inquirer\lib\inquirer.js:65:16) at Object. (myPath\node_modules\inquirer\lib\inquirer.js:77:28) at Module._compile (module.js:397:26) at Object.Module._extensions..js (module.js:404:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object. (myPath\node_modules\node-sp-auth-config\dist\wizards\siteUrl.js:11:16) at Module._compile (module.js:397:26) at Object.Module._extensions..js (module.js:404:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17)

koltyakov commented 6 years ago

Hi @bhalfacre,

Thanks for posting the issue. Any suggestions how to reproduce it?

bhalfacre commented 6 years ago

Hi @koltyakov

I just started a new project. New package.json and new gulpfile.js. Installed gulp, then gulp-spsave. Created a simple gulp task to test my connection to a new SharePoint site collection. Once I created the variable to require gulp-spsave and saved the changes to my gulpfile.js file the error appeared.

koltyakov commented 6 years ago

Can you share your ./config/private.json? Please, don't forget to clear up all sensitive data with abstract dummy values. I just can't reproduce it no matter I tried. And on hundreds of installation within our team projects, no one reported such an issue.

koltyakov commented 6 years ago

Can it be that you're trying to hardcode auth parameters in your gulp file? The idea of node-sp-auth-config is to provide credentials prompts for all node-sp-auth strategies. Strictly provided (hardcoded) creds should be correct due to one of the strategies. Might be an error in auth object I guess.

bhalfacre commented 6 years ago

This very well maybe a problem with how node-sp-auth is utilizing the auth parameters from your package. gulp-spsave > spsave > sp-request > node-sp-auth > node-sp-auth-config is the path of dependencies.

koltyakov commented 6 years ago

gulp-spsave is gulp module - wrapper around spsave, with only gulp specifics. sp-request is a SharePoint-aware request library. node-sp-auth is responsible for different strategies auth processes. node-sp-auth-config is a circular dependency for node-sp-auth for allowing wizard mode. If auth params are correct it isn't triggered. Such dependency tree is pretty justified.

Could you check generator-sppp Yeoman generator? Just create a blank project and try gulp watch within it, will it work for you?

koltyakov commented 6 years ago

Hey @bhalfacre,

Any update on this. Did you manage to overcome your issue? I still need some additional info from you. As I never experince this issue. And we use node-sp-auth in a variety of tools, incliding gulp-spsave and many others.

s-KaiNet commented 6 years ago

BTW I saw this error when trying to run node-sp-auth-config from environment, where prompts are not supported, i.e. vscode add-in. I believe the same might apply to Visual Studio task runner.

koltyakov commented 6 years ago

Hm... good point to check.