Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncss failing at source #74

Closed
ArcaneMainFrame opened this issue Mar 13, 2014 · 21 comments
Closed

Uncss failing at source #74

ArcaneMainFrame opened this issue Mar 13, 2014 · 21 comments

Comments

@ArcaneMainFrame
Copy link

Not sure what I am doing wrong with my grunt configuration. I do have this set locally and I have tried setting the htmlroot and stylesheets but it keeps giving this error with no idea as to why it fails:

Running "uncss:dev"
verifying property
files: index.html -> css/site.css
Options: compress=false, ignore=[""]
Uncssing source "index.html' failed.
Warning: Uncss failed. Use -force to continue

This is my gruntfile task:

uncss: {
dev: {
files: {
'css/site.css': ['index.html']
}
}
}

@addyosmani
Copy link
Member

I'm going to wait until uncss 0.8 lands on npm so we can upgrade and then double-check this issue is still present.

@addyosmani
Copy link
Member

Can you re-check with the latest version? 0.3 is now on npm.

@ArcaneMainFrame
Copy link
Author

This still occurs within the newest version just the error message has changed to Fatal error: bad argument

I am running it off of Windows 7 32bit if that helps in identifying why the module would fail in such a manner.

@addyosmani
Copy link
Member

@giakki are you seeing any similar reports upstream?

@bondz
Copy link

bondz commented Apr 8, 2014

Yes, same error running the command in node.

    Running "uncss:dist" (uncss) task
    Fatal Error: Bad argument

Windows 8.1 64 bit.

@bondz
Copy link

bondz commented Apr 9, 2014

Running grunt with debug and stack trace on

    grunt -d --stack

gives

    [D] Task source: x\node_modules\grunt-uncss\tasks\uncss.js
    Fatal error: Bad argument
TypeError: Bad argument
    at ChildProcess.spawn (child_process.js:923:24)
    at exports.spawn (child_process.js:723:9)
    at spawnPhantom (x\node_modules\grunt-uncss\node_modules\uncss\node_modules\node-phantom-simple\node-phantom-simple.js:70:23)
    at Object.exports.create (x\node_modules\grunt-uncss\node_modules\uncss\node_modules\node-phantom-simple\node-phantom-simple.js:201:5)
    at x\node_modules\grunt-uncss\node_modules\uncss\lib\phantom.js:37:21
    at Object.async.whilst (x\node_modules\grunt-uncss\node_modules\uncss\node_modules\async\lib\async.js:663:13)
    at init (x\node_modules\grunt-uncss\node_modules\uncs\li\phantom.js:34:18)
    at fn (x\node_modules\grunt-uncss\node_modules\uncss\node_modules\async\lib\async.js:626:34)
    at Object._onImmediate (x\page\node_modules\grunt-uncss\node_modules\uncss\node_modules\async\lib\async.js:542:34)
    at processImmediate [as _immediateCallback] (timers.js:330:15)

So, I head over to PhantomJS Website downloaded the newest version, put the executable in a directory in path and the gruntfile runs, thanks for the awesome plugin.

@ArcaneMainFrame
Copy link
Author

@bondz I relatively new to the grunt scene but where exactly did you place this exe file for the plugin to run? I have tried multiple places with no success.

@bondz
Copy link

bondz commented Apr 9, 2014

@ArcaneMainFrame I took the following steps.

  • deleted grunt-uncss from node_modules folder in the same directory as gruntfile.js
  • Placed PhantomJS.exe in the same directory I installed node.exe
  • Reinstalled grunt-uncss

@ArcaneMainFrame
Copy link
Author

This did not solve it, but I figured it out on my own and it was the most unlikely of things. I had changed the default path of command line when it opens to C:\ instead of C:\Users\Username in the regedit with an autorun command. This caused PhantomJS to look into the work places for dependencies. Changing it back to the default fixed the issue.

@juliencap
Copy link

Hello, I have the same error as above and the same result with grunt -d --stack.
Tried to follow your indications with PhantomJS.exe but not a big success.
So my question : phantomjs.exe have to be into the nodejs directory ?
Thanks, I am quit excited to test uncss !

@bondz
Copy link

bondz commented Apr 16, 2014

@juliencap yes. Then reinstall grunt-uncss. You should see something along the lines of phantomjs already installed. Rewriting path to x:\nodejs\phantomjs.exe

@juliencap
Copy link

Thanks for your help, but no progress.
"You should see something along the lines of phantomjs already installed" not understanding "along the lines
"Rewriting path to x:\nodejs\phantomjs.exe" where I have to do that ?
Thanks for your time !

Edit : latest report:

C:\wamp\www\test>grunt -d --stack
Running "clean:tests" (clean) task
[D] Task source: C:\wamp\www\test\node_modules\grunt-contrib-clean\tasks\clean.j
s
Cleaning dist...OK

Running "copy:dist" (copy) task
[D] Task source: C:\wamp\www\test\node_modules\grunt-contrib-copy\tasks\copy.js
Created 3 directories, copied 14 files

Running "uncss:dist" (uncss) task
[D] Task source: tasks\uncss.js
Fatal error: Bad argument
TypeError: Bad argument
at ChildProcess.spawn (child_process.js:923:24)
at exports.spawn (child_process.js:723:9)
at spawnPhantom (C:\wamp\www\test\node_modules\uncss\node_modules\node-phant
om-simple\node-phantom-simple.js:70:23)
at Object.exports.create (C:\wamp\www\test\node_modules\uncss\node_modules\n
ode-phantom-simple\node-phantom-simple.js:201:5)
at C:\wamp\www\test\node_modules\uncss\lib\phantom.js:37:21
at Object.async.whilst (C:\wamp\www\test\node_modules\uncss\node_modules\asy
nc\lib\async.js:663:13)
at init (C:\wamp\www\test\node_modules\uncss\lib\phantom.js:34:18)
at fn (C:\wamp\www\test\node_modules\uncss\node_modules\async\lib\async.js:6
26:34)
at Object._onImmediate (C:\wamp\www\test\node_modules\uncss\node_modules\asy
nc\lib\async.js:542:34)
at processImmediate as _immediateCallback

Execution Time (2014-04-16 19:33:11 UTC)
loading tasks 1.2s ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 84%
clean:tests 46ms ■■ 3%
copy:dist 98ms ■■■■ 7%
uncss:dist 73ms ■■■ 5%
Total 1.4s

@bondz
Copy link

bondz commented Apr 16, 2014

Copy phantomjs to node path.
Delete uncss from C:\wamp\www\test\node_modules\ directory.
Delete grunt-uncss from C:\wamp\www\test\node_modules\ directory

Run npm install uncss
Run npm install grunt-uncss --save-dev

Check that C:\wamp\www\test\node_modules\grunt-uncss\node_modules\uncss\node_modules\phantomjs\lib\location.js contains

module.exports.location = "P:\\ath\\to\\PhantomJS\\phantomjs.EXE"

@juliencap
Copy link

Stil me, I tried your last advices, so delete and run again the install seems ok.

The fact is on : C:\wamp\www\test\node_modules\test\
I dont have location.js file on
\node_modules\uncss\node_modules\phantomjs\libdirectory

(And when I run grunt I still have the same error as above)

Actually on C:\wamp\www\test\node_modules\grunt-uncss I don't have node_modules directory only :

  • tasks (directory)
  • changelog.md
  • License-MIT
    -package.json
  • README.md

and i Have phantomjs.exe on : C:\Program Files\nodejs

So I am probably on total confusion with differents installations !

@bondz
Copy link

bondz commented Apr 17, 2014

Actually, in my node_modules folder, I don't have uncss... The only folder there is grunt-uncss. So, I don't know exactly what might be happening on your machine. I do have uncss in grunt-uncss\node_modules though.

So, maybe try removing the uncss folder from C:\wamp\www\test\node_modules.

Also, might be irrelevant but I don't have node installed in program files, its in a directory without spaces. X:\node\

You can try that after.

@juliencap
Copy link

Ok close to the perfection.
I remove node from program files; installed it on c:
Removed unused node_modules on C:\wamp\www\test\node_modules

Pretty sure my phantomjs on node directory is not executed because my version is 1.9.7.0 (on node directory) and when I run npm install uncss I have at the end of the install that message :

[email protected] install C:\wamp\www\test\node_modules\uncss\node_modules\phantomjs
node install install.js

But I still not find that location.js file's.

I installed other grunt modules to test and it was ok.

Thanks again for your time.

@seminice
Copy link

seminice commented Mar 6, 2015

I'm having the same issue on mountain lion
node 0.12 , 0.11.14 , 0.10.36
I ran the grunt task in debugging mode , and here is the outcome

TypeError: Bad argument
at TypeError (native)
at ChildProcess.spawn (child_process.js:1129:26)
at Object.exports.spawn (child_process.js:988:9)
at app/node_modules/grunt-uncss/node_modules/uncss/node_modules/phridge/lib/spawn.js:82:38
at init (app/node_modules/grunt-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePromise.js:39:5)
at new Promise (app/node_modules/grunt-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePromise.js:27:53)
at Function.promise (app/node_modules/grunt-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/when.js:98:10)
at startPhantom (app/node_modules/grunt-uncss/node_modules/uncss/node_modules/phridge/lib/spawn.js:58:25)
at tryCatchReject (app/node_modules/grunt-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePromise.js:845:30)
at runContinuation1 (app/node_modules/grunt-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePromise.js:804:4)
at Fulfilled.when (app/node_modules/grunt-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePromise.js:592:4)
at Pending.run (app/node_modules/grunt-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/makePromise.js:483:13)
at Scheduler._drain (app/node_modules/grunt-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/Scheduler.js:62:19)
at Scheduler.drain (app/node_modules/grunt-uncss/node_modules/uncss/node_modules/phridge/node_modules/when/lib/Scheduler.js:27:9)
at process._tickCallback (node.js:355:11)

I tried placing the phantom binary in the same directory of the Gruntfile but it didn't work too.
Any help will be really appreciated, and great work anyway.

@seminice
Copy link

seminice commented Mar 6, 2015

Solved it by editing the location.js file in /grunt-uncss/node_modules/uncss/node_modules/phridge/node_modules/phantomjs/lib/location.js
I found out that the file is corrupted or something.

@jikuja
Copy link

jikuja commented Apr 4, 2015

@seminice 👍 Thanks your tip is nice. I just encountered same problem with global phantomjs installation. If you have idea how to reproduce that please tell or open new bug report in https://github.com/ariya/phantomjs/

@mikelambert
Copy link

This appears to be due to a half-completed installation of phantomjs-prebuilt, see this other issue for more info: Medium/phantomjs#533

In my case, following these instructions fixed it for me:

$ cd node_modules/phantomjs-prebuilt
$ node install.js

@deanhume
Copy link

deanhume commented Nov 2, 2016

I followed @mikelambert instructions and this fixed the issue for me too. For some reason, the PhantomJS install never fully completed on MacOS and needed this nudge to complete it...saved me hours of frustration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants