postcss / postcss-cli

CLI for postcss
Other
824 stars 93 forks source link

Unexpected identifier #402

Closed webian closed 2 years ago

webian commented 2 years ago

Hi, I'm new to postcss and I have a problem with a grunt.js that, using postcss+autoprefixer should prefix css but it doesn't.

Trying to find out the cause I ended to simply run: npm i -D postcss postcss-cli and then: npx postcss and it returns only: Unexpected identifier

Please, what could I do to better debug this issue?

webian commented 2 years ago

More info: postcss@8.3.8 postcss-cli@9.0.0

uname -a Linux Acer 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

npm -v 6.14.4

RyanZim commented 2 years ago

Only Unexpected identifier; no stack trace or anything?

webian commented 2 years ago

Yes, only that.

gerardcanal commented 2 years ago

I am getting the same error on a scheduled CI run:

/usr/lib/node_modules/postcss-cli/index.js:3
import fs from 'fs-extra'
       ^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
Error: Process completed with exit code 1.

It was running well last week so I understand this was introduced recently (#401 apparently). I am not sure if I'm missing dependencies, I tried to install the ESM package with no luck (but I don't have much experience with node).

RyanZim commented 2 years ago

What Node version are you running (both of you)?

gerardcanal commented 2 years ago

That was a good point, I was running node 10 and just realised the logs had a deprecation warning, I completely missed that one! It is fixed now (currently on version 14).

webian commented 2 years ago

Thank you @gerardcanal for the idea. I was running node 10 (default for Ubuntu 20.04) and I updated it to 14 using NodeSource PPA and the problem is solved.

RyanZim commented 2 years ago

Yep, postcss-cli v9 requires Node 12 or higher, otherwise, you will get this error.