How to add missing package to exe file in Javascript with pkg - javascript

I am developing a program to send messages by whatsapp through whatsapp-web.js module, I want to make my program an executable, for this I am using "pkg", however when I generate the executable, I get the following message.
Warning Cannot include directory %1 into executable.
The directory must be distributed with executable as %2.
%1: ..\node_modules\puppeteer\.local-chromium
%2: path-to-executable/puppeteer
I already copied the path where it is requested, here you can see it in vscode
However, when I run the executable I get this:
C:\snapshot\romer\node_modules\puppeteer\lib\cjs\puppeteer\node\Launcher.js:105
throw new Error(missingText);
^
Error: Could not find expected browser (chrome) locally. Run `npm install` to download the correct Chromium revision (982053).
at ChromeLauncher.launch (C:\snapshot\romer\node_modules\puppeteer\lib\cjs\puppeteer\node\Launcher.js:105:23)
at PuppeteerNode.launch (C:\snapshot\romer\node_modules\puppeteer\lib\cjs\puppeteer\node\Puppeteer.js:125:31)
at Client.initialize (C:\snapshot\romer\node_modules\whatsapp-web.js\src\Client.js:95:39)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at process.runNextTicks [as _tickCallback] (node:internal/process/task_queues:65:3)
at Function.runMain (pkg/prelude/bootstrap.js:1941:13)
at node:internal/main/run_main_module:17:47
Does anyone know how to solve this error? I have searched in forums but I have not seen anything that helps me, my code in Github: https://github.com/rromerov/Whatsapp-Web-Project/blob/main/codigo.js

Related

Error while creating nuxt3 project. Failed to download template from registry

When I use this command to create a new Nuxt 3 project:
npx nuxi init nuxt-app
It outputs this error:
ERROR (node:1752) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time 09:53:25
(Use `node --trace-warnings ...` to show where the warning was created)
ERROR Failed to download template from registry: fetch failed 09:53:25
at /C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:13269:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async downloadTemplate (/C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:13268:20)
at async Object.invoke (/C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:13336:15)
at async _main (/C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/cli.mjs:50:20)
My environments:
Operating System: Windows 11
node version : 18.12.0
npm version: 8.12.1
At first I suspected that this was due to my network. But I didn't get an error when I tried to install other npm packages.
I got the same issue while working at a client (bank), this is mainly a network restriction indeed. They are limiting the access to only a few NPM packages and this one is not whitelisted (mainly the template).
Not sure how to properly bypass it other than manually getting the code with an SSH/HTTP clone or maybe asking them to allow that specific endpoint.
I found the reason in here.
It's indeed a network issue. It couldn't access raw.githubusercontent.com from the command line because it couldn't find the corresponding IP address.
After adding the correct ip address of raw.githubusercontent.com to the Windows hosts file, the issue was fixed
You can also resolve it by switch your network, like if you on using a wi-fi, please change it with another.

Error when trying to run any Cypress test

I've installed Cypress according to the cypress docs. After opening Cypress and selecting a test to run, I instantly get the following error:
**Title:** Error running plugin
Message: The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (C:\Users\metin\Desktop\Programming\School\Typescript\From JS to TS\cypress\plugins\index.js)
Stack trace:
Error: The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (`C:\Users\metin\Desktop\Programming\School\Typescript\From JS to TS\cypress\plugins\index.js`)
at Object.get (C:\Users\metin\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\lib\errors.js:1043:15)
at EventEmitter.handleError (C:\Users\metin\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\lib\plugins\index.js:189:20)
at EventEmitter.emit (node:events:394:28)
at ChildProcess.<anonymous> (C:\Users\metin\AppData\Local\Cypress\Cache\9.1.0\Cypress\resources\app\packages\server\lib\plugins\util.js:19:22)
at ChildProcess.emit (node:events:394:28)
at emit (node:internal/child_process:920:12)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
I've been googling for a few hours and I'm looking for help on how to resolve this issue!
Uninstall Nodejs
Download the Nodejs (Recommended For Most Users) version from the link:
https://nodejs.org/en/
Install the downloaded Nodejs
I had the same issues
in my case, this issue was related to my bitbucket.yml.file, I changed: max-time:(set time for running your tests) in my job, and everything works fine
If you're using Cucumber then review your step files in search of misspelling keywords or case sensitive typos like wHEN or thEn

Can't run node file using Visual Studio Code terminal

I am trying to execute a file using the terminal included in Visual Studio Code. However, I cannot seem to get it working and end up receiving the following error message:
Example, "node myfile.js" --> module.js:549
throw err;
^
Error: Cannot find module c:\somepath
Is there anyone who knows what the problem might be?
Run Visual studio as Admin and also the Node package location should be accessible for your user
I had your problem before
you should run cmd as administrator.
then type : powershell set-Executionpolicy Remotesigned
and
enter.
now you can run node in vscode .

How to properly connect linter in Atom with jshint

I want to use the linter package in the Atom Editor. I have installed the packages "linter" and "linter-jshint". Additionally I installed jshint via npm (globally) and downloaded the jshint-repo from GitHub.
When I just try to run the linter on an open .js file in Atom, it fails with message "Error running JSHint". The same happens if I point the executablePath for linter-jshint in the Atom config to the downloaded repo folder.
When I set the executablePath to the node.js Module ("linter-jshint": executablePath: "C:/Users/Username/AppData/Roaming/npm/node_modules/jshint") it just shows a warning ("JSHint return an invalid response, check your console for more info"). Developer Tools console shows:
[Linter-JSHint] SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at Object. (main.js:157)
at Generator.next ()
at step (C:\Users\Username.atom\packages\linter-jshint\lib\main.js:3)
at process._tickCallback (internal/process/next_tick.js:103)
What am I doing wrong? Do I have to point to another subdir or a specific file?
Username contains space and a german umlaut "รถ".
PS: I can execute jshint from command line and it works.
On Executable Path field, you should actually point to jshint executable file, like this:
H:\node_modules\jshint\bin\jshint

WebStorm keeps crashing my locally ran server because of Git's index.lock

Error: EPERM: operation not permitted, lstat 'C:\ProjectDirectory\.git\index.lock'
at Error (native)
I'm using WebStorm and everytime I run the local server for testing purposes using npm start, it crashes inevitably sometimes after doing nothing, and sometimes after making a change or so.
I'm using this React boilerplate and the actual author responded to a bug issue I brought up about this saying "Based on the error, it looks like either your editor or your source control system is locking files."
I'm a bit tired restarting the server every time I make a couple changes and would love to fix this.
Full error log
Only IDE have reason to watch .git/ folder. So if something else tries then it's a bug in configuration.
npm start is an alias for npm-run-all --parallel test:watch open:src lint:watch.
Make sure that .git/ is exempted in their configuration.

Categories