XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Solved SyntaxError: Named export 'format' not found. The requested module 'json-rpc-peer' is a CommonJS module

    Xen Orchestra
    4
    8
    1.8k
    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.
    • D
      DeOccultist
      last edited by

      Just tried updating my latest XO community version to the latest but ran into this issue when starting.

      node version is 14.16.1
      npm version is 6.14.12
      yarn version is 1.22.4

      Any ideas as to what this problem is?

      May 25 12:56:32 server-xo systemd[1]: Started XO Server.
      May 25 12:56:33 server-xo xo-server[3211]: file:///opt/xen-orchestra/packages/xo-server/dist/api/disk.mjs:6
      May 25 12:56:33 server-xo xo-server[3211]: import { format } from 'json-rpc-peer';
      May 25 12:56:33 server-xo xo-server[3211]:          ^^^^^^
      May 25 12:56:33 server-xo xo-server[3211]: SyntaxError: Named export 'format' not found. The requested module 'json-rpc-peer' is a CommonJS module, which may not support all module.exports as named exports.
      May 25 12:56:33 server-xo xo-server[3211]: CommonJS modules can always be imported via the default export, for example using:
      May 25 12:56:33 server-xo xo-server[3211]: import pkg from 'json-rpc-peer';
      May 25 12:56:33 server-xo xo-server[3211]: const { format } = pkg;
      May 25 12:56:33 server-xo xo-server[3211]:     at ModuleJob._instantiate (internal/modules/esm/module_job.js:104:21)
      May 25 12:56:33 server-xo xo-server[3211]:     at async ModuleJob.run (internal/modules/esm/module_job.js:149:5)
      May 25 12:56:33 server-xo xo-server[3211]:     at async Loader.import (internal/modules/esm/loader.js:166:24)
      May 25 12:56:33 server-xo xo-server[3211]:     at async Object.loadESM (internal/process/esm_loader.js:68:5)
      May 25 12:56:33 server-xo systemd[1]: xo-server.service: Main process exited, code=exited, status=1/FAILURE
      May 25 12:56:33 server-xo systemd[1]: xo-server.service: Failed with result 'exit-code'.
      May 25 12:56:33 server-xo systemd[1]: xo-server.service: Scheduled restart job, restart counter is at 1.
      May 25 12:56:33 server-xo systemd[1]: Stopped XO Server.
      
      1 Reply Last reply Reply Quote 0
      • DanpD
        Danp Top contributor ๐Ÿ’ช
        last edited by

        You may want to try the recommended solutions from this issue -- https://github.com/vatesfr/xen-orchestra/issues/5784

        gallart created this issue in vatesfr/xen-orchestra

        closed SyntaxError: Cannot use import statement outside a module #5784

        D 1 Reply Last reply Reply Quote 0
        • olivierlambertO
          olivierlambert Vates ๐Ÿช Co-Founder๐Ÿฆธ CEO ๐Ÿง‘โ€๐Ÿ’ผ
          last edited by

          Hi,

          How did you update it?

          1 Reply Last reply Reply Quote 0
          • DanpD
            Danp Top contributor ๐Ÿ’ช
            last edited by

            Try updating to node 14.17, which I believe will solve your issue.

            D 1 Reply Last reply Reply Quote 0
            • D
              DeOccultist @Danp
              last edited by DeOccultist

              @olivierlambert
              I know it's not officially recommended or support but I'm using the updater from https://github.com/Jarli01/xenorchestra_updater

              @danp
              Updated to node 14.17 but still has an error but different...

              May 26 11:45:46 server-xo xo-server[1908]: (node:1908) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
              May 26 11:45:46 server-xo xo-server[1908]: (Use `node --trace-warnings ...` to show where the warning was created)
              May 26 11:45:46 server-xo xo-server[1908]: /opt/xen-orchestra/packages/xo-server/dist/xapi/mixins/index.js:2
              May 26 11:45:46 server-xo xo-server[1908]: import _gpu, * as __gpu from "./gpu";
              May 26 11:45:46 server-xo xo-server[1908]: ^^^^^^
              May 26 11:45:46 server-xo xo-server[1908]: SyntaxError: Cannot use import statement outside a module
              May 26 11:45:46 server-xo xo-server[1908]:     at wrapSafe (internal/modules/cjs/loader.js:984:16)
              May 26 11:45:46 server-xo xo-server[1908]:     at Module._compile (internal/modules/cjs/loader.js:1032:27)
              May 26 11:45:46 server-xo xo-server[1908]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
              May 26 11:45:46 server-xo xo-server[1908]:     at Module.load (internal/modules/cjs/loader.js:933:32)
              May 26 11:45:46 server-xo xo-server[1908]:     at Function.Module._load (internal/modules/cjs/loader.js:774:14)
              May 26 11:45:46 server-xo xo-server[1908]:     at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:199:29)
              May 26 11:45:46 server-xo xo-server[1908]:     at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
              May 26 11:45:46 server-xo xo-server[1908]:     at async Loader.import (internal/modules/esm/loader.js:177:24)
              May 26 11:45:46 server-xo xo-server[1908]:     at async Object.loadESM (internal/process/esm_loader.js:68:5)
              May 26 11:45:46 server-xo systemd[1]: xo-server.service: Main process exited, code=exited, status=1/FAILURE
              May 26 11:45:46 server-xo systemd[1]: xo-server.service: Failed with result 'exit-code'.
              May 26 11:45:46 server-xo systemd[1]: xo-server.service: Scheduled restart job, restart counter is at 89.
              May 26 11:45:46 server-xo systemd[1]: Stopped XO Server.
              May 26 11:45:46 server-xo systemd[1]: Started XO Server.
              
              
              aqua-calcA DanpD 2 Replies Last reply Reply Quote 0
              • aqua-calcA
                aqua-calc @DeOccultist
                last edited by

                @deoccultist said in SyntaxError: Named export 'format' not found. The requested module 'json-rpc-peer' is a CommonJS module:

                https://github.com/Jarli01/xenorchestra_updater

                FYI: I've tried the updater too and getting the same failure

                1 Reply Last reply Reply Quote 0
                • DanpD
                  Danp Top contributor ๐Ÿ’ช @DeOccultist
                  last edited by

                  @deoccultist This was also reported in another thread. If may be due to changes published earlier today.

                  1 Reply Last reply Reply Quote 0
                  • DanpD
                    Danp Top contributor ๐Ÿ’ช
                    last edited by

                    You may want to try the recommended solutions from this issue -- https://github.com/vatesfr/xen-orchestra/issues/5784

                    gallart created this issue in vatesfr/xen-orchestra

                    closed SyntaxError: Cannot use import statement outside a module #5784

                    D 1 Reply Last reply Reply Quote 0
                    • D
                      DeOccultist @Danp
                      last edited by

                      @danp Thanks for the tips...
                      Ran the command to do a force rebuild and started up ok now...

                      sudo curl https://raw.githubusercontent.com/Jarli01/xenorchestra_updater/master/xo-update.sh | bash -s -- -f
                      
                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post