SublimeLinter-contrib-stylelint icon indicating copy to clipboard operation
SublimeLinter-contrib-stylelint copied to clipboard

Complains that `postcss` is not installed

Open satazor opened this issue 9 years ago • 13 comments
trafficstars

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?

satazor avatar Dec 30 '15 14:12 satazor

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

kungfusheep avatar Jan 08 '16 01:01 kungfusheep

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

benkutil avatar Jan 27 '16 17:01 benkutil

Now I see this is related to #18 too.

danielkcz avatar Mar 09 '16 16:03 danielkcz

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 [email protected]: wanted: {"node":">=0.12"} (current: {"node":"0.10.32","npm":"2.1.4"})
[email protected] /usr/local/lib/node_modules/postcss
├── [email protected]
├── [email protected]
└── [email protected] ([email protected])

$ 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
└─┬ [email protected]
  ├── [email protected]
  ├── [email protected]
  └─┬ [email protected]
    └── [email protected]

$ 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 avatar Mar 31 '16 21:03 learntoswim

Running the above in my project directory:

$ npm ls postcss
[email protected] /Users/xxxx/my-project
├── UNMET PEER DEPENDENCY jshint@^2.5.0
└── [email protected]

$ npm ls stylelint
[email protected] /Users/xxxx/my-project
├── UNMET PEER DEPENDENCY jshint@^2.5.0
├─┬ [email protected]
│ └── [email protected]
└── [email protected]

$ 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.

learntoswim avatar Apr 01 '16 14:04 learntoswim

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.

danielkcz avatar Apr 01 '16 15:04 danielkcz

@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...

learntoswim avatar Apr 01 '16 17:04 learntoswim

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.

danielkcz avatar Apr 01 '16 17:04 danielkcz

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.

learntoswim avatar Apr 01 '16 18:04 learntoswim

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).

danielkcz avatar Apr 01 '16 18:04 danielkcz

Exactly. Hopefully this helps others.

learntoswim avatar Apr 01 '16 18:04 learntoswim

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

kungfusheep avatar Apr 07 '16 08:04 kungfusheep

:+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) 

mehas avatar Nov 15 '16 17:11 mehas