christopherwk210 / site-scan

CLI for capturing website screenshots, powered by puppeteer.
MIT License
136 stars 13 forks source link

Getting error SyntaxError: Unexpected token #1

Closed jitendravyas closed 6 years ago

jitendravyas commented 6 years ago
❯ ss youtube.com --full
/Users/jitendravyas/.nvm/versions/node/v6.10.0/lib/node_modules/site-scan/lib/site-scan.js:46
(async () => {
       ^
SyntaxError: Unexpected token (
    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.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
millsoft commented 6 years ago

I get the same error... but with different line numbers.

mike@milmike  /run/media/mike/1TB/xampp/htdocs  ss http://www.milmike.com
/usr/lib/node_modules/site-scan/lib/site-scan.js:46
(async () => {
       ^

SyntaxError: Unexpected token (
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    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.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)

The installation was OK I think.. no errors or warnings.: https://pastebin.com/Mwq0yCEW

jozsefs commented 6 years ago

To run this package the node version needs to support async functions (so v7.6+ or 8+). @christopherwk210 This should be added to the package.json via "engines" prop.

millsoft commented 6 years ago

thanks, I just upgraded to nodejs 8.6.0 and get the following error when trying to ss https://www.google.com:

• Launching chrome...
(node:26305) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: spawn EACCES
(node:26305) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

this is on fedora. I also get the same thing on my ubuntu machine.: https://asciinema.org/a/141227?t=8:49

christopherwk210 commented 6 years ago

Thanks @jozsefs, I've done so in https://github.com/christopherwk210/site-scan/commit/908a0621f3be39772c71005a10c01618f8e41e39.

That looks like a permission error @millsoft. Please update with npm i site-scan -g and try it again. Running with sudo may help, but it should now log the error instead of showing the unhandled exception message which should help narrow down the exact problem.

jitendravyas commented 6 years ago

I ran npm i site-scan -g but still getting same error

christopherwk210 commented 6 years ago

The same error you originally posted? That error is the result of having an incorrect version of node, you need to have node 7.6 or greater.

Tucsky commented 6 years ago

I'm also getting something similar using the latest stable npm & node possible on ubuntu 16 Unhandled promise rejection (rejection id: 1): Error: Chalk template literal is missing 1 closing bracket ('}')

image

christopherwk210 commented 6 years ago

My chalk template was constructed incorrectly, but I've just fixed it in https://github.com/christopherwk210/site-scan/commit/c29362bcd232c765e89182f48d7c490c3f1b0553. Please update with npm i site-scan -g and try again, you should get a more helpful error message this time.

christopherwk210 commented 6 years ago

Note: For those of you on linux distros, make sure you look here which shows the list of dependencies you'll need to have installed. This is not an issue with this repo, but with puppeteer. I tested this myself today and was able to get it running by installing the listed dependencies. You can get them all in one go with:

sudo apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget