[QUESTION] help me understand why this repo results in a syntax error when running with npx
timcash opened this issue · comments
What / Why
help me understand why this repo results in a syntax error when running with npx
/home/timcash/.npm/_npx/330/bin/crawlobot: 1: Syntax error: "(" unexpected
node v12.18.3
npm 6.14.6
Where
What node version are you using?
node v12.18.3
npm 6.14.6
This package isn't published; how are you running it with npx exactly?
Also, npx hides the stack trace; what happens if you run your bin file directly?
i was trying npx https://github.com/timcash/crawlobot "https://google.com"
does it need to be on NPM? I though a git repo or gist would work too.
If I run the the file "bin" points to in package.json it works correctly.
Yes, that should work. What does which npx say, and which node? Is there a chance npx is running with the wrong node version?
timcash@DESKTOP-B2E4QES:~$ which npx
/home/timcash/.nvm/versions/node/v12.18.3/bin/npx
timcash@DESKTOP-B2E4QES:~$ which npm
/home/timcash/.nvm/versions/node/v12.18.3/bin/npm
timcash@DESKTOP-B2E4QES:~$ which node
/home/timcash/.nvm/versions/node/v12.18.3/bin/node
timcash@DESKTOP-B2E4QES:~$ npx https://github.com/timcash/crawlobot "https://google.com"
/home/timcash/.npm/_npx/1350/bin/crawlobot: 1: Syntax error: "(" unexpected
timcash@DESKTOP-B2E4QES:~$
When I run it in node 14, I get this output:
$ npx https://github.com/timcash/crawlobot "https://google.com"
Downloading chromium v792639 - 128.2 Mb [====================] 100% 0.0s
Downloading firefox v1144 - 71.8 Mb [====================] 100% 0.0s
Downloading webkit v1322 - 48.9 Mb [====================] 100% 0.0s
$HOME/.npm/_npx/69030/bin/crawlobot: line 1: syntax error near unexpected token `('
$HOME/.npm/_npx/69030/bin/crawlobot: line 1: `const { webkit } = require("playwright");'
so I think the problem is that this is meant to be a "bin" file, and you're missing a shebang - add #!/usr/bin/env node
as the first line and try again.
That was it thank you!