davidguttman / cssify

Simple middleware for Browserify to add css styles to the browser.
122 stars 19 forks source link

Cannot import css from other modules #46

Closed jamietre closed 8 years ago

jamietre commented 8 years ago

Works in 0.8.0, broken in 1.0.2. The following error is reported by Browserify

When module is installed:

 Cannot find module './....cssify' from 
    'D:\Users\{user}\code\report-server\node_modules\@co\module'

When module is linked:

Cannot find module './....\report-server\node_modulescssify' from
    'D:\Users\{user}\code\@co\module'

It seems to be resolving the path incorrectly...

This is being imported globally, e.g.

var b = browserify().transform(cssify, { global: true});

Obviously I am on windows but it also doesn't work on our linux dev server so doubt it's related.

colmbrady commented 8 years ago

I have also encountered this issue.

Reverting to 0.8 fixes it.

Its probably caused by line 32.

https://github.com/davidguttman/cssify/blob/master/lib/process-css.js#L32

Im using Node v4.2.4 and NPM 3.5.3. It also is a problem in NPM 2.X

leesei commented 8 years ago

I try to require normalize.css with cssify

require('normalize.css'); // normalize.css not found
// Error: Cannot find module 'normalize.css' from ...

require('normalize.css/normalize.css'); 
// html {
//     ^
// ParseError: Unexpected token
ghost commented 8 years ago

There's a number of issues here. It seems like Windows users are most affected by this (?).

0.8 also solved issues for me, and allowed inclusions to work. If you try to work around this issue by using path.resolve, it will appear to work but not actually include the file on build (silent failure!)

ses4j commented 8 years ago

I agree this is a Windows issue, because the Windows backslashes generated by path.relative are being dropped into the moduleSource unescaped and therefore are disappearing. The fix is to escape them or use unixy forward-slashes. For instance, I modified process-css.js

requirePath = requirePath.replace(/\\/g, '\\\\'); or requirePath = requirePath.replace(/\\/g, '/');

I'm going to submit a PR.

colmbrady commented 8 years ago

I encountered this error on Mac - just saying. Ill test to see if it fixes the issue for me today.

ghost commented 7 years ago

any solution here?