Cannot run serialport on windows 10 - node.js

I'm developing an electron app and after several atempts I got stucked in this. The browser inspector returns the below error when loading serialport.
Uncaught Error: Error en una rutina de inicialización de biblioteca de vínculos dinámicos (DLL).
\\?\C:\Users\Administracion\Desktop\manu\Sistemas\recargas_ussd\node_modules\serialport\build\Release\serialport.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
at Object.Module._extensions..node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
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 bindings (C:\Users\Administracion\Desktop\manu\Sistemas\recargas_ussd\node_modules\bindings\bindings.js:81:44)
at Object.<anonymous> (C:\Users\Administracion\Desktop\manu\Sistemas\recargas_ussd\node_modules\serialport\lib\bindings\win32.js:2:36)
In order to use it, I've built it from source using:
npm install --global --production windows-build-tools
Since this wasn't enough, installed manually
https://www.microsoft.com/en-us/download/confirmation.aspx?id=40760
And lately:
npm config set msvs_version 2015
npm install --save --build-from-source serialport
This allows me to build serialport. However I'm still not able to use it.

I was able to run it using:
npm install --save-dev electron-rebuild
Adding this to package.json
"scripts": {
"rebuild": "electron-rebuild -f -w yourmodule"
}
And running
npm run rebuild

Related

AppData-Roaming-npm is empty! 'ERR_DLOPEN_FAILED'

I am trying to create a new Hardhat project. Hardhat gives me some pre-created sol files and some scripts. I am just trying to compile this pre-created project, but an error occurred.
\\?\C:\Users\myuser\Desktop\SolidityProjects\emptyhardhatfinal\node_modules\#nomicfoundation\solidity-analyzer-win32-x64-msvc\solidity-analyzer.win32-x64-msvc.node at Object.Module._extensions..node (node:internal/modules/cjs/loader:1210:18)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\myuser\Desktop\SolidityProjects\emptyhardhatfinal\node_modules\#nomicfoundation\solidity-analyzer\index.js:69:29) at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12) {
code: 'ERR_DLOPEN_FAILED'
}
npm init -y
npm i --dev hardhat
npx hardhat and create a JavaScript project
npm i --dev #nomicfoundation/hardhat-toolbox
`npx hardhat compile``` the error above occurred.
My Node.js version is v16.17.0.
User variables for my.user = C:\Users\myuser\AppData\Roaming\npm
System variables = C:\Program Files\nodejs\
I realized that the "AppData\Roaming\npm" folder is empty. But inside another PC that this project worked well is not empty; there is a "node_modules" folder.
What is the problem and how can I solve this?
Try deleting the node_modules folder and see if the project uses NPM or Yarn and run the npm i or Yarn according to it.

All npm commands are throwing the same error, including version check(npm -v). Unlike other questions Not a single npm command is working

Installed Node version 12.13.0 on windows 10. All npm commands throws the following error:
C:\Users\Jahangeer> npm -v
evalmachine.<anonymous>:27
const { Math, Object } = primordials;
^
ReferenceError: primordials is not defined
at evalmachine.<anonymous>:27:26
at Object.<anonymous>
(C:\Users\Jahangeer\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\fs.js:11:1)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous>
(C:\Users\Jahangeer\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\graceful-
fs.js:3:27)
at Module._compile (internal/modules/cjs/loader.js:956:30)
Tried uninstalling and installing few other older Node versions. The Problem remains.
Use these commands to install node 11 and gulp 3 and check:
npm install -g n
sudo n 11.15.0
npm install gulp#^3.9.1
npm install
npm rebuild node-sass

error cannot find module 'umask'

I just installed nodejs x64 on my Windows 10 computer. I keep all default config,
I open cmd and type:
npm -v
Then i got following error:
module.js:457
throw err;
^
Error: Cannot find module 'umask'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\W10-PRO\AppData\Roaming\npm\node_module\npm\lib\utils\umask.js:1:75)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
Every command start with "npm" create this error and npm cannot uninstall, update itself)
Please help me fix this error?
update your npm
$ npm install npm -g
I would try to update/install NPM
$ npm update -g npm
I know the answer!
Uninstall nodejs.
Delete all references to npm and nodejs (Program Files, Program Files(x86).
Then also delete those in AppData/Roaming (npm and npm-cache to be sure).
Reinstall nodejs.
It works!

node-canvas fail after updating node.js and Electron

Windows 10, Electron app used to work great, using node-canvas lib. Today, at long last updated:
npm -> 2.15.9
node -> 4.5.0
electron-prebuilt -> 1.4.1
then followed instructions to update and rebuild the canvas lib. All dependencies updated, installed canvas#1.5.0 and node-gyp rebuild ran smoothly and successfully
But - running npm start to run the app fails with the following trace:
App threw an error during load
Error: A dynamic link library (DLL) initialization routine failed.
\\?\D:\GoMixApp\web\electron\GoMixApp\node_modules\canvas\build\Release\canvas.node
at Error (native)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:168:20)
at Object.Module._extensions..node (module.js:583:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:168:20)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\GoMixApp\web\electron\GoMixApp\node_modules\canvas\lib\bindings.js:3:18)
Going back and forth for last few hours, I always end up with the same error. Am I doing something stupid?
Thanks
After installing the module, you need to run electron-rebuild
npm install -g electron-rebuild
electron-rebuild -f -w canvas

Error: Cannot find module 'lodash._basetostring'

I cant seem to ran any commands against > npm including > npm help ,> npm uninstall or > npm upgrade
the full error is
module.js:339
throw err;
^
Error: Cannot find module 'lodash._basetostring'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npmlog\node_modules\gauge\node_modules\lodash.pad\index.js:9:20)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
I cant run > npm install lodash._basetostring or npm anything
Tried reinstalling and running 'npm cache clean' but even that didn't work, so here's my solution:
Delete all files from, you may want to backup the files first but those are corrupted anyway.
<user profile directory>\AppData\Roaming\npm\node_modules
and then try running npm command, if this works then there's no need to reinstall, just install npm modules using
npm install -g <package names>
Otherwise uninstall node.js, empty above stated folder and then install node.js.
Don't forget to update npm
npm install npm#latest -g

Resources