{"id":16188404,"url":"https://github.com/konsumer/react-nodewebkit","last_synced_at":"2025-03-19T03:30:40.685Z","repository":{"id":24439478,"uuid":"27841361","full_name":"konsumer/react-nodewebkit","owner":"konsumer","description":"react node-webkit starter project","archived":false,"fork":false,"pushed_at":"2015-09-16T23:17:48.000Z","size":190,"stargazers_count":46,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-17T03:05:02.175Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/konsumer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-10T21:48:09.000Z","updated_at":"2023-12-31T01:24:38.000Z","dependencies_parsed_at":"2022-08-22T23:11:09.155Z","dependency_job_id":null,"html_url":"https://github.com/konsumer/react-nodewebkit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Freact-nodewebkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Freact-nodewebkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Freact-nodewebkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsumer%2Freact-nodewebkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/konsumer","download_url":"https://codeload.github.com/konsumer/react-nodewebkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244350674,"owners_count":20439284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T07:26:30.777Z","updated_at":"2025-03-19T03:30:40.386Z","avatar_url":"https://github.com/konsumer.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-nodewebkit starter\n\nDownload this skeleton if you want a no-nonsense react starter project for making standalone [node-webkit](https://github.com/rogerwang/node-webkit) apps.  It uses [skeleton.css](http://getskeleton.com/) and will get you started super-quick and look rad.\n\nThis project is [MIT licensed](http://opensource.org/licenses/MIT), and although totally not required, I think it'd be real sweet if you told people you started your awesome project using mine.\n\n\n## development\n\nGet started with `npm install`.\n\n### nativeRequire\n\nI like to make node-webkit apps in the browser. It's a lot faster than building a native app \u0026 re-running it when I make changes. Also, an issue that you will run into is that browserify overwrites `require()` to use a browser-context version.  I wanted to solve both things with minimal configuration. You will probably still want to use npm modules, natively (that is the whole point of using node-webkit, right?) I made `nativeRequire` and a non-native shim (in `app/shim.js`.) The idea is that when you really need a native module, you just run `nativeRequire('module')` instead of `require('module')` and make a shim in shim.js for browser-based testing. Pretty slick, eh?\n\n#### example please\n\nHere is an example that uses the `serial` npm module:\n\nLets imagine a world, just for a moment, where I need to get a list of serial ports.\n\n```javascript\nvar serial = nativeRequire('serialport');\nserial.list(function(err, ports){\n    // do stuff with me arggh \u0026 ports on dee open sea\n});\n```\n\nin `app/shim.js`, I make a fake module that does something similar to `serial.list`:\n\n```javascript\n/**\n * Browser-dev shim\n * shim all native modules here\n */\n\n(function(){\n    function shim(name){\n        var fakePorts = [{comName:\"Fake COM1\"}, {comName:\"Fake COM2\"}];\n        \n        switch(name){\n            case 'serialport': return {\n                list: function(cb){\n                    cb(null, fakePorts);\n                }\n            };\n        }\n    }\n\n    window.nativeRequire = (typeof require !== 'undefined') ? require : shim;\n})();\n```\n\nPretty simple, eh?\n\nYou don't need to fake every native module completely, and not doing so can help you keep track of what exactly is needed from the native system, just in case you do native things differently in the future ([cordova](http://cordova.apache.org/), [atom-shell](https://github.com/atom/atom-shell), [CEF](https://code.google.com/p/chromiumembedded/), etc.)\n\n#### more on native modules\n\nFor compiled native modules (like `serialport` in the example above) you will need to compile them specifically for node-webkit:\n\n```\nnpm install -g node-pre-gyp\nnpm install --save serialport\ncd node_modules/serialport\nnode-pre-gyp rebuild --runtime=node-webkit --target=0.11.2 --target_arch=ia32\n```\n\nI also had an [issue](https://github.com/voodootikigod/node-serialport/issues/374) with the serialport native module being put in the wrong folder. I resolved it, like this:\n\n```\nmv node_modules/serialport/build/serialport/v1.4.6/Release/node-webkit-v0.11.2-darwin-ia32/ node_modules/serialport/build/serialport/v1.4.6/Release/node-webkit-v14-darwin-ia32\n```\n\n#### more on browserify\n\nIf you hate this elegant simplicity, feel free to use [browserify options](https://github.com/substack/node-browserify) to do something clever. I put the build options in `package.json`. I imagine you could ignore `serialport` and do a try/catch in your application code to shim it, as needed.\n\n### node run\n\nInstead of using a [proper task-runner](http://gulpjs.com/), I just put tasks inside the `package.json` file to reduce the configuration/dependency overhead \u0026 keep things simple \u0026 light.\n\n*  `npm start` - watch file for changes \u0026 rebuild\n*  `npm test` - run mocha all tests in `test/`\n*  `npm run app` - run node-webkit app\n*  `npm run build` - Build the app as an executable for the current platform\n\nI develop features, like this: `npm start \u0026 open app/index.html`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Freact-nodewebkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonsumer%2Freact-nodewebkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsumer%2Freact-nodewebkit/lists"}