Skip to content

Instantly share code, notes, and snippets.

@HipsterBrown
Last active November 19, 2019 15:17
Show Gist options
  • Save HipsterBrown/ade406d42b07165663b416a48cdc2839 to your computer and use it in GitHub Desktop.
Save HipsterBrown/ade406d42b07165663b416a48cdc2839 to your computer and use it in GitHub Desktop.
Minimal nw.js app using node-serialport
node_modules/
dist/
build_from_source=true
runtime=node-webkit
target=0.28.3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Serialport Test</title>
</head>
<body>
<h1>Testing out serialport</h1>
<script src="./dist/app.js"></script>
</body>
</html>
import { get } from 'lodash';
const Serialport = window.require('serialport');
Serialport.list()
.then(ports => {
ports.forEach(p => console.log(get(p, 'comName')));
})
.catch(console.error)
{
"name": "nw-serialport",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"build": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"lodash": "^4.17.11",
"serialport": "^7.0.2"
},
"devDependencies": {
"webpack": "^4.23.1",
"webpack-cli": "^3.1.2"
}
}
module.exports = {
mode: 'development',
entry: './index.js',
output: {
filename: 'app.js',
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment