kungfusheep / SublimeLinter-contrib-stylelint

this repo is no longer maintained - please see https://github.com/SublimeLinter/SublimeLinter-stylelint
MIT License
116 stars 19 forks source link

Complains that `postcss` is not installed #6

Open satazor opened 8 years ago

satazor commented 8 years ago

Hi,

I've followed the installation steps but I'm getting the following error:

SublimeLinter: chdir not set or invalid, using /Users/satazor/Work/own/redux-boilerplate/src/app/components/css 
SublimeLinter: stylelint: application.css ['/usr/local/bin/node', '/Users/satazor/Library/Application Support/Sublime Text 3/Packages/SublimeLinter-contrib-stylelint/stylelint_wrapper.js', '@'] 
SublimeLinter: stylelint output:
module.js:339
    throw err;
    ^

Error: Cannot find module 'postcss'

But I clearly have postcss installed (both stylelint and postcss are installed locally).

$ node

require('postcss') { [Function: postcss]

Thoughts?

kungfusheep commented 8 years ago

Hi, I've not seen this before but I've just made some changes to the plugin to support using the stylelint CLI. Can you let me know if this resolves your issue once you've updated to 1.0.4?

Cheers

benkutil commented 8 years ago

@kungfusheep I'm also having this issue, I'm updated to 1.0.4.

danielkcz commented 8 years ago

Now I see this is related to #18 too.

learntoswim commented 8 years ago

I'm also having this problem, though I suspect it could be a deeper issue (I am running nvm, I haven't dug to much into that yet...):

Without nvm:

$ npm i postcss -g
npm WARN engine postcss@5.0.19: wanted: {"node":">=0.12"} (current: {"node":"0.10.32","npm":"2.1.4"})
postcss@5.0.19 /usr/local/lib/node_modules/postcss
├── js-base64@2.1.9
├── source-map@0.5.3
└── supports-color@3.1.2 (has-flag@1.0.0)

$ which node
/usr/local/bin/node

$  node
> require('postcss')
Error: Cannot find module 'postcss'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at repl:1:2
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
>
(^C again to quit)
>

With nvm:

$ nvm use 5
Now using node v5.6.0 (npm v3.6.0)

$ which node
/Users/xxxx/.nvm/versions/node/v5.6.0/bin/node

$ npm i postcss -g
/Users/xxxx/.nvm/versions/node/v5.6.0/lib
└─┬ postcss@5.0.19
  ├── js-base64@2.1.9
  ├── source-map@0.5.3
  └─┬ supports-color@3.1.2
    └── has-flag@1.0.0

$ node
> require('postcss')
Error: Cannot find module 'postcss'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at repl:1:1
    at REPLServer.defaultEval (repl.js:252:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:417:12)
    at emitOne (events.js:95:20)
>
(To exit, press ^C again or type .exit)
>
learntoswim commented 8 years ago

Running the above in my project directory:

$ npm ls postcss
reactjs-boilerplate@2.4.0 /Users/xxxx/my-project
├── UNMET PEER DEPENDENCY jshint@^2.5.0
└── postcss@5.0.19

$ npm ls stylelint
reactjs-boilerplate@2.4.0 /Users/xxxx/my-project
├── UNMET PEER DEPENDENCY jshint@^2.5.0
├─┬ lint-staged@0.1.1
│ └── stylelint@3.2.3
└── stylelint@4.5.1

$ node
> require('postcss')
{ [Function: postcss]
  plugin: [Function],
...
}
> require('stylelint')
{ [Function: creator]
  postcss: { [Function] postcssPlugin: 'stylelint', postcssVersion: '5.0.14' },
...
}
>
$

Certainly looks like an issue resolving the dependencies outside of the project directory.

danielkcz commented 8 years ago

Personally I don't think it should use postcss at all. If you see my PR #19, I simply used NodeLinter to call stylelint directly. I am using that for like month now and works nicely.

learntoswim commented 8 years ago

@FredyC I tried to use the changes from your PR, I received this error:

SublimeLinter: stylelint: styles.css ['/Users/xxxx/my-project/node_modules/.bin/stylelint', '--config', '/Users/xxxx/my-project/.stylelintrc'] 
SublimeLinter: stylelint output:

/Users/xxxx/my-project/node_modules/stylelint/dist/rules/indentation/index.js:230
var hierarchyMap = new Map();
                       ^
ReferenceError: Map is not defined

I it's still somewhat nvm related? Hmm...

danielkcz commented 8 years ago

Well, the Map is part of ES6, so most likely you have outdated NodeJS. I am not entirely sure how to find which version supports these new collections, but just try to install latest with nvm.

learntoswim commented 8 years ago

That's my point. My default node instance is 0.10.32. I use nvm to use 5.x... So there's something to think about there.

danielkcz commented 8 years ago

Well but that's not really NVM or this package related. Error itself pops from the stylelint itself which is written using ES6. So if anything you can complain there that they should provide ES5 compatible build. But I would suggest to just forget about that old NodeJS especially when you can afford luxury of NVM (I don't have it on Windows).

learntoswim commented 8 years ago

Exactly. Hopefully this helps others.

kungfusheep commented 8 years ago

hi - please see my comments on #19. cheers.

mehas commented 7 years ago

:+1: Same issue here. Node 6.9.1, stylelint 7.5.0.

SublimeLinter: stylelint output:
module.js:471
    throw err;
    ^

Error: Cannot find module 'postcss'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\User\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter-contrib-stylelint\stylelint_wrapper.js:70:19)
    at Module._compile (module.js:570:32)
    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)