Vietnam

    Nodejs.vn

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags
    • Groups
    • Search

    [Hỏi] Sử dụng nightmare và nodejs trên c9.io

    Node.JS
    0
    7
    1519
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      lamphanqt last edited by

      Xin chào mọi người,
      Mình là thành viên mới ^^ rất vui được làm quen và học hỏi với mọi thành viên trên diễn đàn 🙂
      Mình đang mò mẫm về thằng Nightmare trên nodejs. Nhưng cũng đang đến thế bí nên post lên đây mong các cao thủ diễn đàn chỉ giáo cho vài chiêu 😃
      Tình hình là mình đang dùng https://ide.c9.io/ để run code. Chạy 1 cái example cơ bản của Nightmarejs là tìm kiếm trên wikipedia. (https://preview.c9users.io/lamkent/nightmare1/)
      Tuy nhiên khi debug thì gặp lỗi:
      lamkent:~/workspace $ DEBUG=nightmare* node server.js hello
      nightmare queuing process start +0ms
      nightmare queueing action "goto" for https://www.wikipedia.org +4ms
      nightmare queueing action "type" +3ms
      nightmare queueing action "click" +0ms
      nightmare queueing action "wait" +0ms
      nightmare queueing action "url" +0ms
      nightmare running +1ms
      nightmare electron child process exited with code 1: general error - you may need xvfb +79ms
      nightmare electron child process not started yet, skipping kill. +1ms
      Mấy đêm nay cũng GG đủ thể loại cái lỗi của thằng electron vs xvfb này rồi mà vẫn không giải quyết được cái lỗi "electron child process exited with code 1: general error - you may need xvfb" này.
      Cao nhân nào đã gặp trường hợp này xin chỉ giáo ạ, cám ơn mọi người ^^

      Vũ 1 Reply Last reply Reply Quote 0
      • L
        lamphanqt last edited by

        [Hơi nhiều chuyện] Bonus ngoài lề tí :))
        Trong lúc chờ đợi, mình lại tiếp tục search GG =)) với từ khoá lỗi + c9.io
        =)) bất ngờ là thằng GG nó đã index luôn trang nodejs.vn rồi. Nhanh khiếp thật =))

        P/s: à nhiều chuyện thế thôi, mình tiếp tục GG đây :((
        Ai gặp trường hợp lỗi như mình thì chỉ giáo mình với nhé.

        Vũ 1 Reply Last reply Reply Quote 1
        • Vũ
          Vũ Global Moderator @lamphanqt last edited by

          @lamphanqt Đang tích know-how. Mọi người chung tay chia sẻ giúp đỡ nhau, những người đi sau chỉ cần vào nodejs.vn là đã có thể giải quyết được 80% vấn đề của mình rồi 😃

          Tech-nông
          Email: [email protected]
          Profile: about.me/vunb
          Github: github.com/vunb
          Twitter: twitter.com/nhubaovu

          1 Reply Last reply Reply Quote 0
          • Vũ
            Vũ Global Moderator @lamphanqt last edited by

            @lamphanqt said in [Hỏi] Sử dụng nightmare và nodejs trên c9.io:

            Mình search qua trên Github, có một hướng dẫn như này bạn thử xem:

            Is it running? Generally you want to start Xvfb as a daemon process. Alternatively, you can xvfb-run [xvfb args] node your-nightmare-script.js

            Ref: https://github.com/segmentio/nightmare/issues/602#issuecomment-214881507

            Tech-nông
            Email: [email protected]
            Profile: about.me/vunb
            Github: github.com/vunb
            Twitter: twitter.com/nhubaovu

            L 1 Reply Last reply Reply Quote 0
            • L
              lamphanqt @Vũ last edited by

              Tks mod. Mình thử lệnh: xvfb-run --server-args="-screen 0 1024x768x24" node server.js hello
              thì lỗi: bash: xvfb-run: command not found
              Tiếp tục GG lỗi trên thì ra https://stackoverflow.com/questions/21395640/xvfb-not-found-on-your-system
              => chạy lệnh: sudo apt-get install xvfb
              => ra lỗi: E: Unable to locate package xvfb
              Tiếp tục GG lỗi -> ra (https://askubuntu.com/questions/378558/unable-to-locate-package-while-trying-to-install-packages-with-apt)
              Chạy 2 lệnh
              => sudo apt-get update
              => sudo apt-get install xvfb
              Chạy thử lệnh: xvfb-run --server-args="-screen 0 1024x768x24" node server.js hello
              Gặp lỗi:
              module.js:327
              throw err;
              ^

              Error: Cannot find module '/home/ubuntu/workspace/electron/server.js'
              at Function.Module._resolveFilename (module.js:325:15)
              at Function.Module._load (module.js:276:25)
              at Function.Module.runMain (module.js:441:10)
              at startup (node.js:139:18)
              at node.js:990:3
              => Bí =))
              MOD có thể hướng dẫn thêm cho mình không 🙂

              @Vũ said in [Hỏi] Sử dụng nightmare và nodejs trên c9.io:

              Mình search qua trên Github, có một hướng dẫn như này bạn thử xem:

              Is it running? Generally you want to start Xvfb as a daemon process. Alternatively, you can xvfb-run [xvfb args] node your-nightmare-script.js

              Ref: https://github.com/segmentio/nightmare/issues/602#issuecomment-214881507

              Vũ 1 Reply Last reply Reply Quote 0
              • Vũ
                Vũ Global Moderator @lamphanqt last edited by

                @lamphanqt said in [Hỏi] Sử dụng nightmare và nodejs trên c9.io:

                Chạy thử lệnh: xvfb-run --server-args="-screen 0 1024x768x24" node server.js hello

                File server.js đang nằm ở đâu bạn ?
                Bạn thử chạy với đường dẫn tuyệt đối của file js xem được không ?

                $ xvfb-run --server-args="-screen 0 1024x768x24" node /home/path/to/server.js hello

                Chú ý chạy lệnh: npm install trước khi khởi động nodejs nhé 🙂

                Nếu ko được thử tích hợp xvfb vào chương trình của bạn:

                • Pgk: https://www.npmjs.com/package/xvfb
                • Ref: https://github.com/segmentio/nightmare/issues/602#issuecomment-215101328

                Tech-nông
                Email: [email protected]
                Profile: about.me/vunb
                Github: github.com/vunb
                Twitter: twitter.com/nhubaovu

                1 Reply Last reply Reply Quote 0
                • L
                  lamphanqt last edited by

                  Há há.. OMG it DONE =))
                  cài xong 2 lệnh trên là chạy được rồi MOD ạ. Mà do mình đang ở thư mục electron nên nó ko tìm thấy file server.js (tks MOD chỉ điểm 😃 ).
                  Vậy tóm lại để cho các bạn sau có thể pass qua cái thằng quái đản này (nếu gặp case giống mình) mà vô tình đi lạc vào đây:
                  Mình bắt đầu lại từ đầu nhé:

                  npm init
                  npm install nightmare --save
                  sudo apt-get update
                  sudo apt-get install xvfb
                  xvfb-run --server-args="-screen 0 1024x768x24" node index.js

                  Khi gặp lỗi bash: xvfb-run: command not found thì dùng lệnh

                  sudo apt-get update

                  sau đó cài xvfb bằng lệnh

                  sudo apt-get install xvfb

                  rồi chạy với cú pháp

                  xvfb-run [xvfb args] node your-nightmare-script.js

                  DONE ~ hehe

                  1 Reply Last reply Reply Quote 1
                  • First post
                    Last post
                  $(document).ready(function () { app.coldLoad(); }); }