postcss/postcss-cli

Help: No longer found globally installed plugins

Closed this issue · 4 comments

zmni commented

So, I'm resuming my weekend hobby work after very long break. Update everything to the latest, and then I got this error:

Error: Loading PostCSS Plugin failed: Cannot find module 'plugin-name'.

I installed everything globally: npm i -g ..., it's really simple setup.

package.json

{
  "scripts": {
    "build": "postcss input.css -o output.css"
  }
}

.postcssrc.json

{
  "map": false,
  "plugins": {
    "postcss-import": {},
    "postcss-preset-env": {},
    "cssnano": {
      "options": {
        "safe": false
      },
      "autoprefixer": {
        "add": true
      },
      "discardComments": {
        "removeAll": true
      }
    }
  }
}

What changed? It used to work without problem. I've tried to search, but I couldn't find anything. Only this very same stackoverflow question but unfortunately there is no answer.

Anyone can help me? Thank you.

Installing things globally is a bad practice; you should install everything locally, especially when you're already using an npm script.

zmni commented

Thanks for the advice.

So, it's impossible to make it load global plugins? Can you tell me the latest postcss-cli version that stil uses the old behaviour?

TBH, I never knew it even supported loading global plugins.

zmni commented

I just downgrade to v5.0.1, and I can confirm, this is the last version that can still load global plugins. I thought there might be a new option in version 6 to toggle this behaviour. Just a little confused when it suddenly stopped working as usual.

Thanks @RyanZim.