Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token after install #55

Closed
philliphartin opened this issue Feb 19, 2018 · 17 comments
Closed

SyntaxError: Unexpected token after install #55

philliphartin opened this issue Feb 19, 2018 · 17 comments

Comments

@philliphartin
Copy link

Having installed prettier and @prettier/plugin-php globally, I cannot seem to get prettier to work on any php files, it always results in a syntax error.

Am I doing something wrong?
image

@camflan
Copy link

camflan commented Feb 19, 2018

I'm having the same issue - not using globally installed prettier though.

@mgrip
Copy link
Contributor

mgrip commented Feb 19, 2018

I believe you still need to specify the plugin manually, although that does seem to contradict the prettier docs. @azz or @vjeux do you guys have any more info on how plugins are intended to be run from a cli?

@camflan
Copy link

camflan commented Feb 19, 2018

@mgrip I tried that as well, without luck.

The command I attempted,

yarn prettier --plugin=./node_modules/@prettier/plugin-php app/Http/Controllers/ReserveController.php

here's some more info,

❯: cat package.json | rg "prettier"
    "prettier": "1.10.2",
    "@prettier/plugin-php": "0.0.0-development",
    "eslint-config-prettier": "^2.4.0",
    "eslint-plugin-prettier": "^2.2.0",
    "prettier-eslint": "^8.2.1",


❯: yarn --version
1.3.2

❯: yarn prettier --version
yarn run v1.3.2
$ /Users/camron/src/lodgetools/inntender/node_modules/.bin/prettier --version
1.10.2

edited to use the package.json from the correct branch

@mgrip
Copy link
Contributor

mgrip commented Feb 19, 2018

what's the error you get when manually specifying the plugin? I'm guessing the package might have to be updated on npm - there have been a lot of changes since @azz originally published it

@camflan
Copy link

camflan commented Feb 19, 2018

❯: yarn prettier --plugin=./node_modules/@prettier/plugin-php app/Http/Controllers/ReserveController.php
yarn run v1.3.2
$ /Users/camron/src/lodgetools/inntender/node_modules/.bin/prettier --plugin=./node_modules/@prettier/plugin-php app/Http/Controllers/ReserveController.php

[error] app/Http/Controllers/ReserveController.php: SyntaxError: Unexpected token (1:2)
[error] > 1 | <?php
[error]     |  ^
[error]   2 | 
[error]   3 | namespace InnTender\Http\Controllers;
[error]   4 | 
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@mgrip
Copy link
Contributor

mgrip commented Feb 19, 2018

@vjeux @azz do you guys know how the plugins are intended to be run from the cli? the docs make its seem like plugins are intended to be found automatically, but it doesn't seem like thats happening

@vjeux
Copy link
Contributor

vjeux commented Feb 19, 2018

I don’t know, @azz built all the support for it.

@alexander-akait
Copy link
Member

Confirm don't work as expected

@mgrip
Copy link
Contributor

mgrip commented Feb 20, 2018

Ok think I got something that will at least work for now. 2 main things

  1. you still need to specify the parser
  2. while we're developing you should probably use the repos as dependencies rather than whats published on npm as things are getting updated very quickly

so this should work
yarn add --dev prettier/prettier prettier/plugin-php
prettier --parser=php /some/php/file.php

I can update the readme accordingly

@alexander-akait
Copy link
Member

/cc @azz

@mgrip mgrip mentioned this issue Feb 20, 2018
@mgrip
Copy link
Contributor

mgrip commented Feb 20, 2018

@camflan @pjhartin can you guys see if that worked when you have a chance? if so I'll close this out for now

@mgrip
Copy link
Contributor

mgrip commented Feb 22, 2018

Pretty sure this is working - gonna close for now

@mgrip mgrip closed this as completed Feb 22, 2018
@camflan
Copy link

camflan commented Feb 22, 2018

@mgrip yep, those steps worked. Not sure why reinstalling prettier as prettier/prettier works but my existing install would fail.

Thanks 👍

Sent with GitHawk

@mgrip
Copy link
Contributor

mgrip commented Feb 22, 2018

i believe its because prettier would just add whatever the latest version published to npm is, prettier/prettier references the git repo (and there are recent changes that the plugins rely on)

@camflan
Copy link

camflan commented Feb 22, 2018 via email

@philliphartin
Copy link
Author

@mgrip Thanks, I followed your instructions and all seemed to work well.i did notice however that a number of phpDoc comments within my phone code were being stripped away by prettier though. So I'm not 100% on using it right now.

@azz
Copy link
Member

azz commented Feb 24, 2018

@pjhartin Please raise bugs for those items!

@mgrip Sorry for the delay in responding. Fixing it in prettier/prettier#4038.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants