Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

"Bad argument" error when trying to use the plugin. #8

Closed
f15gdsy opened this issue Oct 20, 2016 · 7 comments
Closed

"Bad argument" error when trying to use the plugin. #8

f15gdsy opened this issue Oct 20, 2016 · 7 comments

Comments

@f15gdsy
Copy link

f15gdsy commented Oct 20, 2016

var err = this._handle.spawn(options);
                         ^

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:289:26)
    at exports.spawn (child_process.js:380:9)
    at Object.exports.execFile (child_process.js:143:15)
    at capturePage (/Users/yifengwu/Desktop/dev/lava-official/node_modules/prerender-spa-plugin/lib/compile-to-html.js:70:26)
    at /Users/yifengwu/Desktop/dev/lava-official/node_modules/prerender-spa-plugin/lib/compile-to-html.js:88:11
    at _invoke (/Users/yifengwu/Desktop/dev/lava-official/node_modules/hapi/lib/server.js:305:20)
    at internals.Server._invoke (/Users/yifengwu/Desktop/dev/lava-official/node_modules/hapi/lib/server.js:375:16)
    at Items.serial (/Users/yifengwu/Desktop/dev/lava-official/node_modules/hapi/lib/server.js:297:14)
    at done (/Users/yifengwu/Desktop/dev/lava-official/node_modules/hapi/node_modules/items/lib/index.js:31:25)
    at Server.finalize (/Users/yifengwu/Desktop/dev/lava-official/node_modules/hapi/lib/connection.js:171:9)
    at Server.g (events.js:291:16)
    at emitNone (events.js:91:20)
    at Server.emit (events.js:185:7)
    at emitListeningNT (net.js:1278:10)
    at _combinedTickCallback (internal/process/next_tick.js:71:11)

I'm using this plugin with vue-cli webpack template.
And here is the code I added in webpack.prod.conf.js:

new PrerenderSpaPlugin(
   path.join(__dirname, '../dist'),
   ['/']
)

The first argument is the root of the built files which has the following file structure:

/dist
   |--- index.html
   |--- /static
        |--- /js
        |--- /css
        |--- /img

Also I came across the same error in the example you provide.
I tried in Node v6.7.0 & v4.6.0

@chrisvfritz
Copy link
Owner

It sounds like phantomjs didn't get installed correctly for whatever reason. You can try to install it again with:

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

@f15gdsy
Copy link
Author

f15gdsy commented Oct 20, 2016

Thanks! It solved my problem!

@f15gdsy f15gdsy closed this as completed Oct 20, 2016
@xxqh
Copy link

xxqh commented Dec 29, 2016

@chrisvfritz Hellow, I have found this problem when I execute "npm run build" . And I install phantomjs again, but it can't solve my problem. I try it on Windows X64 System. Looking forward to your reply.

@chrisvfritz
Copy link
Owner

I'll need more information to help you. Versions of node and NFM would be helpful, as well as the full stack trace of the error.

@xxqh
Copy link

xxqh commented Dec 29, 2016

Thank you for your reply. My Node v4.4.4

`> node build/build.js

| building for production...internal/child_process.js:274
var err = this._handle.spawn(options);
^
TypeError: Bad argument
at TypeError (native)
at ChildProcess.spawn (internal/child_process.js:274:26)
at exports.spawn (child_process.js:362:9)
at Object.exports.execFile (child_process.js:151:15)
at capturePage (E:\Project\project\prerender-spa-plugin-vue-demo-mas
ter\prerender-spa-plugin-vue-demo-master\node_modules\prerender-spa-plugin\lib\c
ompile-to-html.js:70:26)
at E:\Project\project\prerender-spa-plugin-vue-demo-master\prerender
-spa-plugin-vue-demo-master\node_modules\prerender-spa-plugin\lib\compile-to-htm
l.js:89:11
at E:\Project\project\prerender-spa-plugin-vue-demo-master\prerender
-spa-plugin-vue-demo-master\node_modules\hapi\lib\server.js:305:20
at internals.Server._createCache.internals.Server.start.internals.Server.ini
tialize.internals.Server._start.internals.Server.stop.invoke.internals.Server.
invoke.next [as _invoke] (E:\Project\project\prerender-spa-plugin-vue-de
mo-master\prerender-spa-plugin-vue-demo-master\node_modules\hapi\lib\server.js:3
75:16)
at E:\Project\project\prerender-spa-plugin-vue-demo-master\prerender
-spa-plugin-vue-demo-master\node_modules\hapi\lib\server.js:297:14
at done (E:\Project\project\prerender-spa-plugin-vue-demo-master\pre
render-spa-plugin-vue-demo-master\node_modules\hapi\node_modules\items\lib\index
.js:31:25)
at Server.finalize (E:\Project\project\prerender-spa-plugin-vue-demo
-master\prerender-spa-plugin-vue-demo-master\node_modules\hapi\lib\connection.js
:171:9)
at Server.g (events.js:260:16)`

I was build the example you provide.And I install phantomjs again

E:\Project\project\prerender-spa-plugin-vue-demo-master\prerender-spa-pl ugin-vue-demo-master\node_modules\phantomjs-prebuilt>node install.js Found PhantomJS at E:\Project\project\prerender-spa-plugin-vue-demo-mast er\prerender-spa-plugin-vue-demo-master\node_modules\phantomjs-prebuilt\lib\phan tom\bin\phantomjs.exe ...verifying PhantomJS is previously installed at E:\Project\project\prerender-spa-pl ugin-vue-demo-master\prerender-spa-plugin-vue-demo-master\node_modules\phantomjs -prebuilt\lib\phantom\bin\phantomjs.exe

@ghost
Copy link

ghost commented Mar 23, 2017

Hi,

This is basically an installation error of PhantomJS anyway. You can try this http://stackoverflow.com/questions/34293504/phantomjs-not-working-anymore-installed-through-npm and tell us if it solves your problem.

Thanks

@galinkaro
Copy link

galinkaro commented Aug 7, 2018

I've had the same error and just npm rebuild command helped me!
For some reason, npm reinstalling did not help..

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

No branches or pull requests

4 participants