creativetimofficial / material-kit

Free and Open Source UI Kit for Bootstrap 5, React, Vue.js, React Native and Sketch based on Google's Material Design
https://www.creative-tim.com/product/material-kit?ref=mk-creativetimofficial-github
MIT License
5.91k stars 1.35k forks source link

Having problems getting this to work on wsl #181

Open ImAliMoussa opened 4 years ago

ImAliMoussa commented 4 years ago

I am on a windows machine running microsoft's bash terminal, also called wsl (windows subsystem for linux) and I am unable to run material kit properly.

So I did npm run open-app and got this error:

`> material-kit@2.0.7 open-app /mnt/c/Users/ali/Desktop/webdev/tmp/material-kit-master

gulp open-app [19:19:41] Using gulpfile /mnt/c/Users/ali/Desktop/webdev/tmp/material-kit-master/gulpfile.js [19:19:41] Starting 'open-app'... [19:19:41] Starting 'open'... [19:19:41] Starting 'watch'... [19:19:42] Opening /mnt/c/Users/ali/Desktop/webdev/tmp/material-kit-master/index.html using the default OS app (node:2007) UnhandledPromiseRejectionWarning: Error: Exited with code 1 at ChildProcess. (/mnt/c/Users/ali/Desktop/webdev/tmp/material-kit-master/node_modules/opn/index.js:84:13) at Object.onceWrapper (events.js:422:26) at ChildProcess.emit (events.js:315:20) at ChildProcess.EventEmitter.emit (domain.js:547:15) at maybeClose (internal/child_process.js:1051:16) at Socket. (internal/child_process.js:442:11) at Socket.emit (events.js:315:20) at Socket.EventEmitter.emit (domain.js:547:15) at Pipe. (net.js:670:12) (Use node --trace-warnings ... to show where the warning was created) (node:2007) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:2007) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.`

So I open the file the material-kit-master/node_modules/opn/index.js file and scrolled to line 84 and after reading the file and a lot of console.log()'s of variables I ended up with this very very hacky solution. Basically I spawn a child process with argument 'cmd.exe' and argument absolute path to material kit index.html. Basically I removed all elements in the args array but the last one.

So I added this line: args = [args[args.length - 1]];

before this one: const cp = childProcess.spawn(cmd, args, cpOpts); in the material-kit-master/node_modules/opn/index.js file/

It worked. But it doesn't watch the index.html file. So like if I added code it doesn't automatically refresh in the browser, which isn't ideal. I would appreciate any help :)