defunctzombie / npm-css

Require css from npm
MIT License
128 stars 8 forks source link

importing packages by name results in "module not found" #15

Closed zedd45 closed 10 years ago

zedd45 commented 10 years ago

running (globally installed) npm-css via:

npm-css index.css -o test.css

is resulting in:

/usr/local/lib/node_modules/npm-css/node_modules/resolve/lib/sync.js:32
    throw new Error("Cannot find module '" + x + "'");
          ^
Error: Cannot find module 'normalize-css'
    at Function.module.exports [as sync] (/usr/local/lib/node_modules/npm-css/node_modules/resolve/lib/sync.js:32:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm-css/index.js:66:36)
    at walker (/usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:190:22)
    at /usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:208:29
    at Array.forEach (native)
    at forEach (/usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:298:31)
    at walker (/usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:203:13)
    at /usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:208:29
    at Array.forEach (native)
    at forEach (/usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:298:31)

I've tried with two modules (Leaflet & Normalize), and both are having the same issue.

Here's the CSS:

/* import packages here to get their CSS from the package.json "style" property */
@import "normalize-css";
@import "leaftlet";

Here's an excerpt from package.json:

{
  "style": "public/css/core.css",
  "dependencies": {
    "leaflet": "~0.7.2",
    "normalize-css": "~2.3.0",
    "npm-css": "~0.2.3"
  }
}

Any idea what I'm doing wrong?

I tried installing the packages to devDependencies, but that didn't fix the issue (nor did I expect it to from perusing the source).

defunctzombie commented 10 years ago

Does normalize-css have a style field in package.json? Sometimes people publish but that doesn't mean it will work with npm-css On Apr 8, 2014 3:29 PM, "Chris Keen" notifications@github.com wrote:

running (globally installed) npm-css via:

npm-css index.css -o test.css

is resulting in:

/usr/local/lib/node_modules/npm-css/node_modules/resolve/lib/sync.js:32 throw new Error("Cannot find module '" + x + "'"); ^ Error: Cannot find module 'normalize-css' at Function.module.exports as sync at Object. (/usr/local/lib/node_modules/npm-css/index.js:66:36) at walker (/usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:190:22) at /usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:208:29 at Array.forEach (native) at forEach (/usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:298:31) at walker (/usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:203:13) at /usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:208:29 at Array.forEach (native) at forEach (/usr/local/lib/node_modules/npm-css/node_modules/traverse/index.js:298:31)

I've tried with two modules (Leaflet & Normalize), and both are having the same issue.

Here's the CSS:

/* import packages here to get their CSS from the package.json "style" property */@import "normalize-css";@import "leaftlet";

Here's an excerpt from package.json:

{ "style": "public/css/core.css", "dependencies": { "leaflet": "~0.7.2", "normalize-css": "~2.3.0", "npm-css": "~0.2.3" }}

Any idea what I'm doing wrong?

I tried installing the packages to devDependencies, but that didn't fix the issue (nor did I expect it to from perusing the source).

Reply to this email directly or view it on GitHubhttps://github.com/defunctzombie/npm-css/issues/15 .

zedd45 commented 10 years ago

yeah, they both do (but I know what you mean about it sometimes being excluded):

Leaflet's package.json:

{
  "style": "dist/leaflet.css"
}

normalize package.json:

{
"style": "normalize.css"
}

I've tried removing one or the other, but it hasn't resolved my problem.

defunctzombie commented 10 years ago

the normalize-css package does not have a style field. Look at the file that installed on your system, not some other repo :)

zedd45 commented 10 years ago

http://necolas.github.io/normalize.css/

I appreciate you taking the time to look into these issues, but you are incorrect in this case; I installed normalize-css via npm, and it does have a style field in it's package.json. I linked the package.json from the repo and I pasted the style property in the ticket.

I will take another look at rework or another alternative solution, but I really liked the magic of being able to npm install my libraries and use a build tool to create a browserify bundle and npm-css to bundle my CSS dependencies..

defunctzombie commented 10 years ago

Maybe I installed the wrong version but I did not see a style field in the file that got installed on my system On Apr 8, 2014 10:19 PM, "Chris Keen" notifications@github.com wrote:

http://necolas.github.io/normalize.css/

I appreciate you taking the time to look into these issues, but you are incorrect in this case; I installed normalize-css via npm, and it _does_have a style field in it's package.json. I linked the package.json from the repo and I pasted the style property in the ticket.

I will take another look at rework or another alternative solution, but I really liked the magic of being able to npm install my libraries and use a build tool to create a browserify bundle and npm-css to bundle my CSS dependencies..

Reply to this email directly or view it on GitHubhttps://github.com/defunctzombie/npm-css/issues/15#issuecomment-39922620 .

zedd45 commented 10 years ago

Ah! there's a "normailze-css" and a "normalize.css" (and normalizecss and normalize.css-browser) published to npm! So I was incorrect that you were incorrect!

Thanks again for taking the time and sorry for my confusion over the package names.

zedd45 commented 10 years ago

In case someone else runs into this problem, it turns out it's the same issue (name collision) for Leaflet. I fixed the issue by using the github url style in my package.json.

"leaflet": "Leaflet/Leaflet"

for whatever reason "npm install leaflet" actually gets a slightly different version where "style" is unset and there are no index.css files in either of these two instances.

Again, thanks for your time and sorry for the confusion, but I hope this helps someone else down the line.

colllin commented 8 years ago

Thanks @zedd45 . I was having a similar issue. Leaflet master has a "style" listing in package.json, but the latest stable (0.7.7) does not.