Hi I really liked your tutorial since it goes to the point, the problem I have is that although it creates the executable when I try to run it I get an error saying it can't find the module, it is not an issue on my node project since that one runs fine, does someone know what could be causing that issue?
Thank you for this tutorial! Indeed, pkg is very good, but it really struggles when it comes to complicated projects with a lot of 3rd party dependencies.
I use OBS as my screen recorder. And you can see a full list of all my gear here. vincentlab.net/gear And I'm currently looking for some new video ideas, so would you be interested in seeing a full video on how I film my development videos?
I don't know of a direct way to do it, but you can use Resource Hacker, here's a video on how to do it. th-cam.com/video/9B_LZN7EEW0/w-d-xo.html And a link to Resource Hacker: www.angusj.com/resourcehacker/
Weird, it used to work fine but I get the same error now, so my recommendation would be to downgrade either Resource Hacker, pkg, or both. I also found this exact issue on this forum post so maybe that will be useful to check out: github.com/vercel/pkg/issues/91 And this was the last time it worked for me, so maybe try to find a version around that date: 30-10-2020 16:45 European Time.
Did you install it using the -g parameter? like this npm install -g pkg and after installing did you try closing the application and reopening it and then typing the command again? what operating system are you using? and what version of node are you running? I will need all of the above information to help you the best.
I tried to do the same thing, but what if you add node_modules to your dependency and delete the node_modules it doesn't work. Do you have any suggestions for that scenario?
The node_modules folder is created automatically and should not be included. So if you're storing anything other than npm packages in there, don't. But if you need to store something, then make another folder that's not named node_modules like the folder I showed in the example called images. And when you built the executable, the node_modules folder will be automatically included. Or maybe I shouldn't say automatically "included" Because what actually happens is that when it's building the executable, it will look at your package.json, to see what dependencies your project has, and then it will run an npm install. So really no need to mess around with the node_modules folder.
@@VincentLabStudio yeah I see the problem. so in my case I build my modules as an npm package and use them, hence I have been failing to use this. thanks anyways
It depends on the operating system, but here are a few packages that might solve the problem. www.npmjs.com/package/node-windows www.npmjs.com/package/node-linux www.npmjs.com/package/node-mac coreybutler.github.io/node-windows/manual/#!/api/nodewindows.Service
I failed to install pkg (see below), could you help? PS C:\HPN\JS odejs odejsscheduler> npm i pkg -g npm WARN deprecated har-validator@5.1.5: this library is no longer supported C:\Users\thinkcentre\AppData\Roaming pm\pkg -> C:\Users\thinkcentre\AppData\Roaming pm ode_modules\pkg\lib-es5\bin.js + pkg@4.5.0 added 173 packages from 183 contributors in 5.963s PS C:\HPN\JS odejs odejsscheduler> pkg -h pkg : The term 'pkg' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + pkg -h + ~~~ + FullyQualifiedErrorId : CommandNotFoundException
@@m.saefulanwar I don't know of any other way to do it, try to search for "how to change the icon of an exe" because that's essentially all it is at this point, hope it helps.
I want to transform an html5 game i made to exe ... can I do that with this? I can do it with NW js but you have to do sort of make a json file yourself .. and it's annoying ... I just wanna load my index file and hit export as exe
The short answer is yes. And I have added an additional example that you can download at the link below. But I would not recommend using it, I would instead use something like Electron JS. Electron JS in 100 Seconds th-cam.com/video/m3OjWNFREJo/w-d-xo.html Example github.com/VLabStudio/Tutorials/tree/master/How%20to%20Bundle%20your%20Node.js%20application%20into%20an%20executable%20for%20Windows%2C%20Linux%2C%20and%20OS%20X/web%20game%20server
Yes, If you watch one of my latest videos, you can see that the text has increased, so yes, I have noticed it an increased it. Thanks for the constructive criticism
if we no need of sever and just wanted to run few commands on the user's system, then i've used pkg and added assets in package.json and made executable using pkg packge.json, but at the runtime its showing the path of the files as /snapshot/project/utils/filename but not using those files actually, so command is getting failed in user's system ...do we need to set any permission to access the asset folder or like express.static in server case...or any other way to do it. (for path m using path.join(__dirname,'utils/'))
@@VincentLabStudio Thanks for reply ...i've found a different way, that is, on running the exe, we can make the same directory structure in local as of assets in local using fs.writeFileStream after fs.readFileStream and write to local current folder using path.join(process.cwd(),fileName), and after using the files, at the time of completion, m removing the local structure directory. Thats it!!!
Gr8thBoy GT That's cool, probably something I would have done as well when I was younger. So you're definitely on the right track to become a computer genius. 😁 And good luck with your project.
@@VincentLabStudio ye i am using inquirer fs child_process axios (first time) express and decompress (to decompress the tar.gz file) packages ive used in node.js jomx (my encryption or something) express fs axios (first time) decompress tar zlib express socket.io ws current-weather-data weather-js discord.js inquirer mysql child_process
@@DeveloVooshGWeb Wow, that's a lot of packages, there were a few of them I hadn't heard of and look pretty interesting (decompress, ws) So I think I'll add them to my video idealist.
Could you copy or take a screenshot of the exact error message? And what operating system you are using. And the version of NPM and Node. node -v to get the Node.js version npm -v to get the NPM version
when i run '$npm install -g pkg', I got this error:' npm WARN deprecated mkdirp@0.5.3: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)'. cannot find a solution on Google.
When I run the command without a dollar sign in front, it works. "npm install -g pkg". But maybe it is your npm/node version you can test that by doing "npm -v". My version is 6.9.0 and my node version is v12.11.1 The node version you can get by doing "node -v". So maybe you can try to update to that version and see if it works. Please let me know if it worked.
@@binarysaiyan9389 Sorry I don't understand nexe well enough to solve your problem. But you could always try pkg. Or try to downgrade your version of Node.js like a few people suggested. www.npmjs.com/package/pkg
PS C:\Users\Kb\Documents\JSProjects> pkg pkg : The term 'pkg' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + pkg + ~~~ + CategoryInfo : ObjectNotFound: (pkg:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
pkg : The term 'pkg' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try -> Getting this error in my powershell
This is an old answer, but I still think it applies in your case. When I run the command without a dollar sign in front, it works fine. "npm install -g pkg". But maybe it is your npm/node version you can test that by doing "npm -v". My version is 6.9.0 and my node version is v12.11.1 The node version you can get by doing "node -v". So maybe you can try to update to that version and see if it works. Please let me know if it worked?
@@VincentLabStudio Hey, so my problem was that I had installed python on my system after nodejs. So I had to make a few changes in my ENV VARIABLES (bring the nodejs path above python) then reopen the powershell and it worked like a charm.
Hello! Thanks for the video! I am a bit confused, how can we read two integers from the command line after executing the program? readline() seems not working for me. pkg@4.4.9 npm is 6.14.5 pkg compiles the js file, but when I try to run it from cmd, it shows me: "pkg/prelude/bootstrap.js:1320 return wrapper.apply(this.exports, args); ^ ReferenceError: readline is not defined" Do you know what can be the problem? code: var line = readline().split(' ') Thanks!
Warning Cannot include file %1 into executable. The file must be distributed with executable as %2. %1: node_modules/node-notifier/vendor/notifu/notifu.exe %2: path-to-executable/notifier/notifu.exe
@@Apollo30 do you sit by your PC to do YT binging? personally I like to sit on a couch or be in bed to watch movies :-) channels with most success think about a number of screen formats, it's the point of doing videos for potential watchers
Hi I really liked your tutorial since it goes to the point, the problem I have is that although it creates the executable when I try to run it I get an error saying it can't find the module, it is not an issue on my node project since that one runs fine, does someone know what could be causing that issue?
How could I do to make my executable work anywhere on my pc ?
Please share what I can do if the user doesn't have nodeJs installed in his machine?
Thank you for this tutorial!
Indeed, pkg is very good, but it really struggles when it comes to complicated projects with a lot of 3rd party dependencies.
what if you have index.ts and uses multiple files like a.ts
Hi... PKG doesn't work for Node.JS 32bit?
Please tell which mic and screen recorder u using?
I use OBS as my screen recorder. And you can see a full list of all my gear here. vincentlab.net/gear
And I'm currently looking for some new video ideas, so would you be interested in seeing a full video on how I film my development videos?
I also recently got some new gear, which I go over in this video. Just skip about 4 minutes in.
th-cam.com/video/pZaboL-Q3sk/w-d-xo.html
is there a way to automatically open the localhost3000?
great i want to include localdatabase how can i do
i mean this app can be run without hosting database or xamm and else
This is great! Is there anything we can do where clicking on the executable can open your browser on localhost rather than us manually doing it?
I think this is what you're looking for:
th-cam.com/video/-4_VhdqtOgs/w-d-xo.html
thanks man, this video is really helpfull
Hi, when i try to node ....js it says not able to build for 'linux' only for 'win' can you help me sir
Can you please tell me How to make the express app installable like other apps? I don't like this cmd window.
Here is the second part of this video, where I go over how to make an installer for Windows: th-cam.com/video/1AUNLoOgLYg/w-d-xo.html
Hello, how can I change the icon exe from pkg?
I don't know of a direct way to do it, but you can use Resource Hacker, here's a video on how to do it. th-cam.com/video/9B_LZN7EEW0/w-d-xo.html
And a link to Resource Hacker: www.angusj.com/resourcehacker/
@@VincentLabStudio I did that but when I run the program it doesn't work and he tells me Pkg: Error reading from file.
Weird, it used to work fine but I get the same error now, so my recommendation would be to downgrade either Resource Hacker, pkg, or both.
I also found this exact issue on this forum post so maybe that will be useful to check out: github.com/vercel/pkg/issues/91
And this was the last time it worked for me, so maybe try to find a version around that date: 30-10-2020 16:45 European Time.
pkg main.js command not working..it says pkg not found any command.even i had intalled it
Did you install it using the -g parameter? like this
npm install -g pkg and after installing did you try closing the application and reopening it and then typing the command again? what operating system are you using?
and what version of node are you running?
I will need all of the above information to help you the best.
@@VincentLabStudio thanks ..it's working now when I reopened it after installation
it's giving this error i have node v20.15.0 installed Warning Failed to make bytecode node14-x64 for file
I tried to do the same thing, but what if you add node_modules to your dependency and delete the node_modules it doesn't work. Do you have any suggestions for that scenario?
The node_modules folder is created automatically and should not be included. So if you're storing anything other than npm packages in there, don't. But if you need to store something, then make another folder that's not named node_modules like the folder I showed in the example called images. And when you built the executable, the node_modules folder will be automatically included. Or maybe I shouldn't say automatically "included" Because what actually happens is that when it's building the executable, it will look at your package.json, to see what dependencies your project has, and then it will run an npm install. So really no need to mess around with the node_modules folder.
@@VincentLabStudio yeah I see the problem. so in my case I build my modules as an npm package and use them, hence I have been failing to use this. thanks anyways
My left ear enjoyed this tutorial
O have a few bat and node applications.How can I merge all into an exe?
Make an installer. I've linked a video down below which shows you how to make one.
th-cam.com/video/1AUNLoOgLYg/w-d-xo.html
jesus, I need a scanning electron microscope to read the text in the video
How to hide the black screen? how to show something else?
Is there a way to run it in the background without the user sieeng it? And also run everytike the system starts
It depends on the operating system, but here are a few packages that might solve the problem.
www.npmjs.com/package/node-windows
www.npmjs.com/package/node-linux
www.npmjs.com/package/node-mac
coreybutler.github.io/node-windows/manual/#!/api/nodewindows.Service
I failed to install pkg (see below), could you help?
PS C:\HPN\JS
odejs
odejsscheduler> npm i pkg -g
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
C:\Users\thinkcentre\AppData\Roaming
pm\pkg -> C:\Users\thinkcentre\AppData\Roaming
pm
ode_modules\pkg\lib-es5\bin.js
+ pkg@4.5.0
added 173 packages from 183 contributors in 5.963s
PS C:\HPN\JS
odejs
odejsscheduler> pkg -h
pkg : The term 'pkg' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ pkg -h
+ ~~~
+ FullyQualifiedErrorId : CommandNotFoundException
Which version of NPM and Node.js are you using?
Use these commands to test:
npm -v
node -v
@@VincentLabStudio thanks a lot for taking your time to reach me, I found the problem. it is actually my windows, preventing running script, I solved.
Very good tutorial, maybe you could show how to build an installer for the folder and the exe sometime in the future
Thanks ! It's great !
Glad you like it!
How to change icon?
You can use Resource Hacker, here's a video on how to do it: th-cam.com/video/9B_LZN7EEW0/w-d-xo.html
@@VincentLabStudio I have tried it, but there is an error.
@@m.saefulanwar I don't know of any other way to do it, try to search for "how to change the icon of an exe" because that's essentially all it is at this point, hope it helps.
I want to transform an html5 game i made to exe ... can I do that with this? I can do it with NW js but you have to do sort of make a json file yourself .. and it's annoying ... I just wanna load my index file and hit export as exe
The short answer is yes. And I have added an additional example that you can download at the link below. But I would not recommend using it, I would instead use something like Electron JS.
Electron JS in 100 Seconds
th-cam.com/video/m3OjWNFREJo/w-d-xo.html
Example
github.com/VLabStudio/Tutorials/tree/master/How%20to%20Bundle%20your%20Node.js%20application%20into%20an%20executable%20for%20Windows%2C%20Linux%2C%20and%20OS%20X/web%20game%20server
hey boby, did you watch you videos before upload?
It's to read this small font's.
Yes, If you watch one of my latest videos, you can see that the text has increased, so yes, I have noticed it an increased it. Thanks for the constructive criticism
@@VincentLabStudio you have a big screen jajajajaja
if we no need of sever and just wanted to run few commands on the user's system, then i've used pkg and added assets in package.json and made executable using pkg packge.json, but at the runtime its showing the path of the files as /snapshot/project/utils/filename but not using those files actually, so command is getting failed in user's system ...do we need to set any permission to access the asset folder or like express.static in server case...or any other way to do it. (for path m using path.join(__dirname,'utils/'))
I've also had issues with that feature, maybe try Nexe instead, maybe it works better with that feature:
th-cam.com/video/Ef7ZklmAPVk/w-d-xo.html
@@VincentLabStudio Thanks for reply ...i've found a different way, that is, on running the exe, we can make the same directory structure in local as of assets in local using fs.writeFileStream after fs.readFileStream and write to local current folder using path.join(process.cwd(),fileName), and after using the files, at the time of completion, m removing the local structure directory. Thats it!!!
Mono audio 🥰
Annoying.
Sup vince
This time im making a gdps
And im making a web installer
What is gdps?
@@VincentLabStudio geometry dash private server
Gr8thBoy GT That's cool, probably something I would have done as well when I was younger. So you're definitely on the right track to become a computer genius. 😁 And good luck with your project.
@@VincentLabStudio ye i am using
inquirer
fs
child_process
axios (first time)
express
and decompress (to decompress the tar.gz file)
packages ive used in node.js
jomx (my encryption or something)
express
fs
axios (first time)
decompress
tar
zlib
express
socket.io
ws
current-weather-data
weather-js
discord.js
inquirer
mysql
child_process
@@DeveloVooshGWeb Wow, that's a lot of packages, there were a few of them I hadn't heard of and look pretty interesting (decompress, ws) So I think I'll add them to my video idealist.
When I run the pkg command, it says something about a security error. I don't know how to fix this. Do you?
Could you copy or take a screenshot of the exact error message? And what operating system you are using. And the version of NPM and Node.
node -v to get the Node.js version
npm -v to get the NPM version
i would just put cmd.exe were the file is and run as admin and do command in there and will do fine
:D
Short + informative = very useful, thanks.
Thanks for the comment.
when i run '$npm install -g pkg', I got this error:' npm WARN deprecated mkdirp@0.5.3: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)'. cannot find a solution on Google.
When I run the command without a dollar sign in front, it works.
"npm install -g pkg". But maybe it is your npm/node version you can test that by doing "npm -v". My version is 6.9.0 and my node version is v12.11.1 The node version you can get by doing "node -v". So maybe you can try to update to that version and see if it works. Please let me know if it worked.
thanks for the video bro very short infromation lol
TypeError: Cannot read property 'set' of undefined
Could you be more specific?
@@VincentLabStudio github.com/nexe/nexe/issues/768
@@binarysaiyan9389 Sorry I don't understand nexe well enough to solve your problem. But you could always try pkg. Or try to downgrade your version of Node.js like a few people suggested.
www.npmjs.com/package/pkg
@@VincentLabStudio What did you think, I didn't try that? The modules I used won't work on the previous versions
PS C:\Users\Kb\Documents\JSProjects> pkg
pkg : The term 'pkg' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ pkg
+ ~~~
+ CategoryInfo : ObjectNotFound: (pkg:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
npm install -g pkg
you saved my life, thank you!!!!
Glad it helped!
pkg : The term 'pkg' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that
the path is correct and try -> Getting this error in my powershell
This is an old answer, but I still think it applies in your case.
When I run the command without a dollar sign in front, it works fine.
"npm install -g pkg". But maybe it is your npm/node version you can test that by doing "npm -v". My version is 6.9.0 and my node version is v12.11.1 The node version you can get by doing "node -v". So maybe you can try to update to that version and see if it works. Please let me know if it worked?
@@VincentLabStudio Hey, so my problem was that I had installed python on my system after nodejs. So I had to make a few changes in my ENV VARIABLES (bring the nodejs path above python) then reopen the powershell and it worked like a charm.
@@VincentLabStudio Also thank you for you reply. Hope this info helps someone :)
5:00 Great! I would reccomend to just get the photo from a cloud or something like that.
Thanks
Thank you.
AWESOME!! How i can put a custom icon?
I don't know of a direct way to do it, but you can use Resource Hacker, here's a video on how to do it.
th-cam.com/video/9B_LZN7EEW0/w-d-xo.html
And a link to Resource Hacker: www.angusj.com/resourcehacker/
Thank you
Really good video, helped a lot.
How to convert nodejs+mongodb as executable file?
As far as I know, that's not possible. But you could go with a local file database like lowdb.
www.npmjs.com/package/lowdb
cool lille demo :-)
I didn't even know this thing existed.. Lol🤣🤣 thankyou🙏
Narrator speaks very quickly, and the text on the screencapture is far too small to read.
A bit of advice, maybe a bigger font is better, so we can vision this with our mobile phone, good jobs anyway
Thanks for the suggestion. I will increase the font-size. And thank you for the lovely comment.
لا
@@VincentLabStudio kypiopplpplphip klinik jh jkhn km lypie km l hulk l lulllk
my left ear is not happy
Yes. it was an error on my side while rendering the videos, but in later videos it's fixed.
@@VincentLabStudio but my knowledge is satisfied
Hello! Thanks for the video! I am a bit confused, how can we read two integers from the command line after executing the program? readline() seems not working for me.
pkg@4.4.9
npm is 6.14.5
pkg compiles the js file, but when I try to run it from cmd, it shows me:
"pkg/prelude/bootstrap.js:1320
return wrapper.apply(this.exports, args);
^
ReferenceError: readline is not defined"
Do you know what can be the problem?
code:
var line = readline().split(' ')
Thanks!
Try running this code, it works for me.
// Import dependencies
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question("Number One? ", (numberOne) => {
rl.question("Number Two? ", (numberTwo) => {
console.log(`Number One + Number Two == ${+numberOne + +numberTwo}`);
rl.close();
});
});
Its secure?
What do you mean by secure? If you mean if the code could be extracted, then the answer is yes, it can.
Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/node-notifier/vendor/notifu/notifu.exe
%2: path-to-executable/notifier/notifu.exe
sorry for those people who broke their left headphones
Is it normal that I only hear you in my left ear ?
Yes. it was an error on my side while rendering the videos but in later videos it's fixed.
I don't get why we're watching an almost empty screen when things are actually impossible to read when watching on a smartphone... :-
Thank you for your suggestion. In my newer videos, I have increased the font size, and trying to zoom in as well when possible, so it's not so static.
Why are you watching a tutorial meant for pc on a smartphone..
@@Apollo30 do you sit by your PC to do YT binging? personally I like to sit on a couch or be in bed to watch movies :-) channels with most success think about a number of screen formats, it's the point of doing videos for potential watchers
@@PierreSoubourou I do in fact binge watch youtube videos, but binge watching coding videos is something that has never crossed my mind.
all ı understood it was not possible
had to take headphones off, why is it on my left ear
I know that the audio is only playing out of one ear. I have fixed it in newer videos. But thanks for making me aware anyway. 🙂
god damn, 37Mb for hello world project
Yeah, that's one of the drawbacks of using Node.js in this way.
24