How to Bundle your Node.js application into an executable for Windows, Linux, and OS X

แชร์
ฝัง

ความคิดเห็น • 126

  • @1KillerQueen3
    @1KillerQueen3 3 หลายเดือนก่อน +1

    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?

  • @Noukhba-TV
    @Noukhba-TV ปีที่แล้ว

    How could I do to make my executable work anywhere on my pc ?

  • @rupbhaiya
    @rupbhaiya 2 ปีที่แล้ว +1

    Please share what I can do if the user doesn't have nodeJs installed in his machine?

  • @BGSlimBG
    @BGSlimBG ปีที่แล้ว +1

    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.

  • @sohilahmed7302
    @sohilahmed7302 ปีที่แล้ว

    what if you have index.ts and uses multiple files like a.ts

  • @doidopb
    @doidopb 3 ปีที่แล้ว

    Hi... PKG doesn't work for Node.JS 32bit?

  • @bala-st9cj
    @bala-st9cj 4 ปีที่แล้ว +1

    Please tell which mic and screen recorder u using?

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว +1

      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?

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      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

  • @jayvinf2p782
    @jayvinf2p782 ปีที่แล้ว

    is there a way to automatically open the localhost3000?

  • @khantsithuphyo5484
    @khantsithuphyo5484 2 ปีที่แล้ว

    great i want to include localdatabase how can i do
    i mean this app can be run without hosting database or xamm and else

  • @tootyrnt5533
    @tootyrnt5533 3 ปีที่แล้ว +3

    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?

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว +3

      I think this is what you're looking for:
      th-cam.com/video/-4_VhdqtOgs/w-d-xo.html

  • @arfeenmushtaq4273
    @arfeenmushtaq4273 ปีที่แล้ว

    thanks man, this video is really helpfull

  • @trajigt3075
    @trajigt3075 2 ปีที่แล้ว

    Hi, when i try to node ....js it says not able to build for 'linux' only for 'win' can you help me sir

  • @hanuunturjuman4360
    @hanuunturjuman4360 2 ปีที่แล้ว

    Can you please tell me How to make the express app installable like other apps? I don't like this cmd window.

    • @VincentLabStudio
      @VincentLabStudio  2 ปีที่แล้ว +1

      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

  • @قهوهبندله
    @قهوهبندله 3 ปีที่แล้ว +1

    Hello, how can I change the icon exe from pkg?

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว

      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/

    • @قهوهبندله
      @قهوهبندله 3 ปีที่แล้ว

      @@VincentLabStudio I did that but when I run the program it doesn't work and he tells me Pkg: Error reading from file.

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว

      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.

  • @rinkuchoudhary226
    @rinkuchoudhary226 3 ปีที่แล้ว

    pkg main.js command not working..it says pkg not found any command.even i had intalled it

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว +1

      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.

    • @rinkuchoudhary226
      @rinkuchoudhary226 3 ปีที่แล้ว

      @@VincentLabStudio thanks ..it's working now when I reopened it after installation

  • @abcoding9415
    @abcoding9415 6 หลายเดือนก่อน

    it's giving this error i have node v20.15.0 installed Warning Failed to make bytecode node14-x64 for file

  • @nakulgawande1507
    @nakulgawande1507 3 ปีที่แล้ว +1

    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?

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว +1

      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.

    • @nakulgawande1507
      @nakulgawande1507 3 ปีที่แล้ว +1

      @@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

  • @TheDuck4Eva
    @TheDuck4Eva หลายเดือนก่อน

    My left ear enjoyed this tutorial

  • @lobby596
    @lobby596 3 ปีที่แล้ว

    O have a few bat and node applications.How can I merge all into an exe?

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว

      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

  • @koggism
    @koggism 3 ปีที่แล้ว +1

    jesus, I need a scanning electron microscope to read the text in the video

  • @hanuunturjuman4360
    @hanuunturjuman4360 2 ปีที่แล้ว

    How to hide the black screen? how to show something else?

  • @adilismail3593
    @adilismail3593 4 ปีที่แล้ว

    Is there a way to run it in the background without the user sieeng it? And also run everytike the system starts

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      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

  • @hpnguyen2002
    @hpnguyen2002 3 ปีที่แล้ว

    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

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว +1

      Which version of NPM and Node.js are you using?
      Use these commands to test:
      npm -v
      node -v

    • @hpnguyen2002
      @hpnguyen2002 3 ปีที่แล้ว

      @@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.

  • @gameunderground
    @gameunderground ปีที่แล้ว +1

    Very good tutorial, maybe you could show how to build an installer for the folder and the exe sometime in the future

  • @trungphunguyen8703
    @trungphunguyen8703 2 ปีที่แล้ว

    Thanks ! It's great !

  • @m.saefulanwar
    @m.saefulanwar 2 ปีที่แล้ว

    How to change icon?

    • @VincentLabStudio
      @VincentLabStudio  2 ปีที่แล้ว

      You can use Resource Hacker, here's a video on how to do it: th-cam.com/video/9B_LZN7EEW0/w-d-xo.html

    • @m.saefulanwar
      @m.saefulanwar 2 ปีที่แล้ว

      @@VincentLabStudio I have tried it, but there is an error.

    • @VincentLabStudio
      @VincentLabStudio  2 ปีที่แล้ว

      ​@@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.

  • @jessicawinslet684
    @jessicawinslet684 4 ปีที่แล้ว

    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

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      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

  • @wxIyz
    @wxIyz 4 ปีที่แล้ว +1

    hey boby, did you watch you videos before upload?
    It's to read this small font's.

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว +1

      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

    • @wxIyz
      @wxIyz 4 ปีที่แล้ว

      @@VincentLabStudio you have a big screen jajajajaja

  • @shashankbhatnagar7984
    @shashankbhatnagar7984 3 ปีที่แล้ว

    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
      @VincentLabStudio  3 ปีที่แล้ว

      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

    • @shashankbhatnagar7984
      @shashankbhatnagar7984 3 ปีที่แล้ว

      @@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!!!

  • @Dstonephoto
    @Dstonephoto 3 ปีที่แล้ว +5

    Mono audio 🥰

  • @DeveloVooshGWeb
    @DeveloVooshGWeb 4 ปีที่แล้ว +3

    Sup vince
    This time im making a gdps
    And im making a web installer

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      What is gdps?

    • @DeveloVooshGWeb
      @DeveloVooshGWeb 4 ปีที่แล้ว +1

      @@VincentLabStudio geometry dash private server

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      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.

    • @DeveloVooshGWeb
      @DeveloVooshGWeb 4 ปีที่แล้ว

      @@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

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว +1

      ​@@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.

  • @_fragment
    @_fragment 4 ปีที่แล้ว

    When I run the pkg command, it says something about a security error. I don't know how to fix this. Do you?

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      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

    • @MagmaMcNet
      @MagmaMcNet 4 ปีที่แล้ว +1

      i would just put cmd.exe were the file is and run as admin and do command in there and will do fine
      :D

  • @amirnazari6427
    @amirnazari6427 4 ปีที่แล้ว +2

    Short + informative = very useful, thanks.

  • @caiyu9373
    @caiyu9373 4 ปีที่แล้ว

    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.

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      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.

  • @fatmanurerturk374
    @fatmanurerturk374 2 ปีที่แล้ว

    thanks for the video bro very short infromation lol

  • @binarysaiyan9389
    @binarysaiyan9389 4 ปีที่แล้ว +1

    TypeError: Cannot read property 'set' of undefined

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      Could you be more specific?

    • @binarysaiyan9389
      @binarysaiyan9389 4 ปีที่แล้ว

      @@VincentLabStudio github.com/nexe/nexe/issues/768

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      @@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

    • @binarysaiyan9389
      @binarysaiyan9389 4 ปีที่แล้ว

      @@VincentLabStudio What did you think, I didn't try that? The modules I used won't work on the previous versions

  • @keithschaub7863
    @keithschaub7863 2 ปีที่แล้ว +1

    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

    • @shxrkdotdev
      @shxrkdotdev ปีที่แล้ว +1

      npm install -g pkg

  • @northernlightz_
    @northernlightz_ 3 ปีที่แล้ว

    you saved my life, thank you!!!!

  • @abhishekchavan1307
    @abhishekchavan1307 3 ปีที่แล้ว

    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

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว

      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?

    • @abhishekchavan1307
      @abhishekchavan1307 3 ปีที่แล้ว

      @@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.

    • @abhishekchavan1307
      @abhishekchavan1307 3 ปีที่แล้ว

      @@VincentLabStudio Also thank you for you reply. Hope this info helps someone :)

  • @BastelPichi
    @BastelPichi 3 ปีที่แล้ว

    5:00 Great! I would reccomend to just get the photo from a cloud or something like that.

  • @dev688
    @dev688 3 ปีที่แล้ว +2

    Thanks

  • @mattiadevigus6242
    @mattiadevigus6242 4 ปีที่แล้ว

    AWESOME!! How i can put a custom icon?

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      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

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      And a link to Resource Hacker: www.angusj.com/resourcehacker/

    • @mattiadevigus6242
      @mattiadevigus6242 4 ปีที่แล้ว

      Thank you

  • @regal_7877
    @regal_7877 4 ปีที่แล้ว +1

    Really good video, helped a lot.

  • @sanstinykitchen4682
    @sanstinykitchen4682 3 ปีที่แล้ว

    How to convert nodejs+mongodb as executable file?

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว

      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

  • @linckez958
    @linckez958 4 ปีที่แล้ว +2

    cool lille demo :-)

  • @adwaithks
    @adwaithks 4 ปีที่แล้ว +1

    I didn't even know this thing existed.. Lol🤣🤣 thankyou🙏

  • @weisjerry
    @weisjerry 2 ปีที่แล้ว

    Narrator speaks very quickly, and the text on the screencapture is far too small to read.

  • @keratonJava
    @keratonJava 4 ปีที่แล้ว

    A bit of advice, maybe a bigger font is better, so we can vision this with our mobile phone, good jobs anyway

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว +1

      Thanks for the suggestion. I will increase the font-size. And thank you for the lovely comment.

    • @user-oq3re8bf2v
      @user-oq3re8bf2v 3 ปีที่แล้ว

      لا

    • @babalupasman8471
      @babalupasman8471 3 ปีที่แล้ว

      @@VincentLabStudio kypiopplpplphip klinik jh jkhn km lypie km l hulk l lulllk

  • @ricopohl2064
    @ricopohl2064 3 ปีที่แล้ว +2

    my left ear is not happy

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว +1

      Yes. it was an error on my side while rendering the videos, but in later videos it's fixed.

    • @ricopohl2064
      @ricopohl2064 3 ปีที่แล้ว +1

      @@VincentLabStudio but my knowledge is satisfied

  • @nursultandzhumabaev8943
    @nursultandzhumabaev8943 4 ปีที่แล้ว

    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!

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว +1

      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();
      });
      });

  • @SkillerM0
    @SkillerM0 4 ปีที่แล้ว

    Its secure?

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      What do you mean by secure? If you mean if the code could be extracted, then the answer is yes, it can.

  • @neb542
    @neb542 ปีที่แล้ว

    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

  • @pixelsymbols
    @pixelsymbols 3 ปีที่แล้ว

    sorry for those people who broke their left headphones

  • @Cecemel
    @Cecemel 4 ปีที่แล้ว

    Is it normal that I only hear you in my left ear ?

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว

      Yes. it was an error on my side while rendering the videos but in later videos it's fixed.

  • @PierreSoubourou
    @PierreSoubourou 3 ปีที่แล้ว

    I don't get why we're watching an almost empty screen when things are actually impossible to read when watching on a smartphone... :-

    • @VincentLabStudio
      @VincentLabStudio  3 ปีที่แล้ว +1

      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.

    • @Apollo30
      @Apollo30 3 ปีที่แล้ว

      Why are you watching a tutorial meant for pc on a smartphone..

    • @PierreSoubourou
      @PierreSoubourou 3 ปีที่แล้ว

      @@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

    • @Apollo30
      @Apollo30 3 ปีที่แล้ว

      @@PierreSoubourou I do in fact binge watch youtube videos, but binge watching coding videos is something that has never crossed my mind.

  • @kdmmedikal7375
    @kdmmedikal7375 หลายเดือนก่อน

    all ı understood it was not possible

  • @applefan2762
    @applefan2762 4 ปีที่แล้ว +1

    had to take headphones off, why is it on my left ear

    • @VincentLabStudio
      @VincentLabStudio  4 ปีที่แล้ว

      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. 🙂

  • @_slier
    @_slier 2 ปีที่แล้ว

    god damn, 37Mb for hello world project

    • @VincentLabStudio
      @VincentLabStudio  2 ปีที่แล้ว

      Yeah, that's one of the drawbacks of using Node.js in this way.

  • @DeepakKumar-mk2yp
    @DeepakKumar-mk2yp 4 ปีที่แล้ว

    24