node-serialport: 'The "path" argument must be of type string. Received type undefined' in Quasar Framework
Good day! I’m trying to play around using serialport and Electron from Quasar Framework for Arduino projects. When I try to run my project, this error occurs instead of running gracefully.
NodeError: The "path" argument must be of type string. Received type undefined
at assertPath (path.js:39:11)
at dirname (path.js:1270:5)
at Function.getRoot (webpack-internal:///../node_modules/bindings/bindings.js:151:13)
at bindings (webpack-internal:///../node_modules/bindings/bindings.js:60:32)
at eval (webpack-internal:///../node_modules/@serialport/bindings/lib/linux.js:1:92)
at Object.../node_modules/@serialport/bindings/lib/linux.js (http://localhost:8080/0.js:89:1)
at __webpack_require__ (http://localhost:8080/app.js:768:30)
at fn (http://localhost:8080/app.js:131:20)
at eval (webpack-internal:///../node_modules/@serialport/bindings/lib/index.js:14:22)
at Object.../node_modules/@serialport/bindings/lib/index.js (http://localhost:8080/0.js:67:1)
logError @ vue.runtime.esm.js?e832:1737
Here’s my code snippet: [Vue.js]
import SerialPort from 'serialport'
.....
created () {
const port = new SerialPort('/dev/ttyUSB0', {baudRate: 9600})
port.on('data', (data) => {
console.log('Data: ' + data)
})
}
The error occurs during the line import SerialPort from 'serialport'
. I also tried using const SerialPort = require('serialport')
but the issue persists. I’ve already tried researching for about half a day and still can’t find any solutions.
Here’s my current environment: [package.json]
"scripts": {
"install": "electron-rebuild"
},
"dependencies": {
"serialport": "^7.0.2"
},
"devDependencies": {
"babel-eslint": "^8.2.1",
"devtron": "1.4.0",
"electron": "3.0.8",
"electron-debug": "2.0.0",
"electron-devtools-installer": "2.2.4",
"electron-packager": "^12.0.1",
"electron-rebuild": "^1.8.2",
"eslint": "^4.18.2",
"eslint-config-standard": "^11.0.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.0.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.3.0",
"quasar-cli": "^0.17.0",
"strip-ansi": "=3.0.1"
},
"engines": {
"node": ">= 8.9.0",
"npm": ">= 5.6.0",
"yarn": ">= 1.6.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 10"
]
serialport: ^7.0.2 Node.js: v11.2.0 npm: 6.4.1 OS: Kubuntu Linux 18.04
Thank you in advance for the help. 😃
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 20 (4 by maintainers)
I tried cloning https://github.com/johnny-five-io/electron-serialport and it works, seems that there is some magic going on with Quasar. Anyway, I’ve already give up on this for now. I’ll try this again next time if I have some time.
@saintcrawler - I did get this working once I’d correctly read your reply. It’s been a week of red herrings, as serialport has it’s own foibles, needing a recompile from source to get node versions to match, plus my own machine issues, like updating to MacOs Sierra but not upgrading Xcode. Thanks again.
Same problem. Electron + serialport works fine. When I add webpack, the error comes.
This works for me, maybe it will be helpful for somebody.
https://stackoverflow.com/a/46554944