Error: serialport in node_modules throwing unexpected token SyntaxError

I have been attempting to run the vue-electron app, but I keep encountering this error.

  App threw an error during load
  C:\newFolder02\pos4-desktop\node_modules\@serialport\stream\lib\index.js:103
    const settings = { ...defaultSettings, ...options }
                       ^^^

  SyntaxError: Unexpected token ...
      at createScript (vm.js:74:10)
      at Object.runInThisContext (vm.js:116:10)
      at Module._compile (module.js:533:28)
      at Object.Module._extensions..js (module.js:580:10)
      at Module.load (module.js:503:32)
      at tryModuleLoad (module.js:466:12)
      at Function.Module._load (module.js:458:3)
      at Module.require (module.js:513:17)
      at require (internal/module.js:11:18)
      at Object.<anonymous> (C:\newFolder02\pos4-desktop\node_modules\serialport\lib\index.js:1:175)

The error is originating from this particular line of code.

const settings = { ...defaultSettings, ...options }

The tools I am using are:

  • node 8.16.0
  • npm 6.4.1
  • electron 1.8.2

This issue seems to be specific to Windows as it works fine on Mac OS. Any suggestions on how to resolve this?

Answer №1

After some research, I have discovered a solution. By utilizing Babel (found at https://babeljs.io/en/repl), you can easily convert ES6 code to its original JavaScript counterpart.

I successfully converted the ES6 code to pure vanilla JavaScript using Babel. To achieve this, I enabled the ENV PRESET option in the left sidebar. Additionally, I specified Electron as "1.8" and Node as "8.16". The conversion process went smoothly and the output was exactly what I needed. View Babel Screenshot

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Updating fields in a MongoDB collection with identical names

I am seeking guidance on how to update all instances of 'list_price' within a complex collection like this: "cost_price" : 79.9, "list_price" : 189.9, "sale_price" : 189.9, "integrations" : { "erp" : { "mbm" : { "cost_pri ...

Is it possible to modify content in a Laravel post using formData?

Working on a social network, I encountered an issue when trying to enable post editing. The error message displayed is: message: "This action is unauthorized." Despite following the flow of sending data through Axios calls and defined routes to the contr ...

What is the best way to specify the parameter for updating the value of a specific property within an object that is stored in an array?

Looking to update the quantity value based on the title in the movies array and Item id (123). I've successfully updated the value at the first layer (name: David), but now I need help updating the second layer with an additional filter for the array ...

Why is my Vue list not showing the key values from a JavaScript object?

I am struggling to utilize a v-for directive in Vue.js to display the keys of a JavaScript object in a list. Initially, the object is empty but keys and values are populated based on an API call. Here's an example of the data structure (I used JSON.st ...

The function returning the map finished before the foreach loop

I recently created a program that computes totals by multiplying a given rate with some hours. However, I've encountered an issue with the getTasks() function always returning an empty map. Even though the fields entered in the map are not empty, the ...

I'm working on separating the functionality to edit and delete entries on my CRM model, but I'm having trouble finding a way to connect these buttons with my data fields

I am encountering some difficulties while trying to implement separate functionality for editing and deleting items on my CRM model. I have already created the necessary API in Angular, but I am struggling to bind these buttons with my field. Any assistanc ...

Synchronizing data between two Vue components when deleting an item

Feeling uncertain about the approach I am taking with this data. Essentially, I have the following dataset: surrounding: { data: [ { id: 1, name: 'test' }, { id: 2, name: 'test' }, { id: 3, name: 'test& ...

Tips for sending data to Jade templates:1. Use the `locals`

Review the code below user.js exports.index = function (req, res){ res.render('user', { id: req.params.id }); }; user.jade body - var x = #{id} div.container div.headpic if (x < 10) ...

What is the best way to switch from using Promise to using await in ES7?

My main issue with Promise is the difficulty in understanding and using resolve and reject. The need to wrap code in Promise can also be cumbersome and forgettable if not used frequently. Additionally, code involving Promise tends to be messy and hard to r ...

npm: Utility for identifying neglected flag packages or evaluating them against specific standards

Seeking a tool or npm package to verify our used npm packages against specific criteria, such as being updated within the last 6 months or having a certain license like MIT. It seems that finding a solution for checking the last update date is not easy. I ...

Facing a NodeJS 404 error while working on the Angular state API with UI-Router

I am currently working on a nodejs angular app. The Nodejs server is up and running smoothly. I have set up ui router with html5mode enabled. When I try to access http://localhost:3000/superadmin, Nodejs returns a 404 error. However, if I access the rout ...

Fixing permission issues during the installation of Angular Client on MacOS: A comprehensive guide

As a beginner coder diving into Angular and Node through an Udemy tutorial, I've encountered some issues. While I have successfully installed Node.js version 16.15.1, my attempts to install the angular client have consistently failed (see screenshot a ...

Determining the optimal scenarios for utilizing debug compared to alternative logging frameworks

NodeJS offers two well-known logging frameworks: winston and Bunyan. Additionally, there is a tool called debug. From my understanding, all of these tools essentially serve the same purpose - which is to log information. debug comes as a default component ...

Choosing between Vue.use and Vue.component for the main Vue component

When using Vue.use, the functionality becomes global, similar to when calling Vue.component in the root Vue component like app.vue. I recently came across a sample app that utilized both methods, with multiple calls of Vue.component and Vue.use within the ...

Searching for the specific JSON object within an array in PostgreSQL using TypeORM and Node.js

Issue Description @Entity({name: 'reports'}) export class Report extends BaseEntity { @PrimaryGeneratedColumn() public id: number; @Column({name: 'dates_parsed', type: 'jsonb'}) public datesParsed: any; } I need to retriev ...

How can I trigger the modal if emitting "go-modal" at another instance does not work?

I have implemented the standard vuetifyjs/dialogs on my page without any server-side scripts. The layout of the components on the page is structured as follows: <div id="main"> ... <v-expansion-panel>...<!-- v-for... --> <v ...

ERROR occurred in the renderer.js file due to an unexpected punctuation token «(»

Version: webpack 2.3.3 Hello, I am currently working on developing my first Electron app using Vuejs. The process has been smooth so far until I encountered an issue during the packaging phase. Running npm run dev works perfectly fine, but when I execut ...

Problem related to permissions within a node.js package

Introducing my newly built npm module called emeraldfw, now available for public use. Here is a glimpse of the contents in my package.json file: { "name": "emeraldfw", "version": "0.6.0", "bin": "./emeraldfw.js", "description": "Emerald Framework ...

Navigate through fabricated data not appearing in Express application

I have come across a handlebars template file within my Express app: {{#each data}} <article class="id-{{this.id}}"> <h1><a href="/journal/{{this.url}}">{{this.title}}</a></h1> <p>{{this.body}}</p> </ar ...

Is there a way to verify that a promise has been successfully awaited, rather than just created, using Sinon?

Imagine having a function: const someAction = async(): Promise<string> => { /* do stuff */ }; And there is code that simply needs to execute this action without caring about the result. However, there is a mistake - the action is not set to ...