<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[SyntaxError: Cannot use import statement outside a module]]></title><description><![CDATA[<p dir="auto">I'm updating xo-orchestra following this page:<br />
[<a href="https://xen-orchestra.com/docs/from_the_sources.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://xen-orchestra.com/docs/from_the_sources.html</a>](link url)</p>
<p dir="auto">and getting the following messages:</p>
<pre><code>root@xenorchestra:/opt/xen-orchestra# node -v
v14.17.0
root@xenorchestra:/opt/xen-orchestra# npm -v
6.14.13
root@xenorchestra:/opt/xen-orchestra#  yarn -v
1.22.5
root@xenorchestra:/opt/xen-orchestra# cd packages/xo-server
root@xenorchestra:/opt/xen-orchestra/packages/xo-server# yarn start
yarn run v1.22.5
$ node dist/cli.mjs
(node:1189) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/opt/xen-orchestra/packages/xo-server/dist/xapi/mixins/index.js:2
import _gpu, * as __gpu from "./gpu";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:984:16)
    at Module._compile (internal/modules/cjs/loader.js:1032:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at ModuleWrap.&lt;anonymous&gt; (internal/modules/esm/translators.js:199:29)
    at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
    at async Loader.import (internal/modules/esm/loader.js:177:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
</code></pre>
]]></description><link>https://xcp-ng.org/forum/topic/4630/syntaxerror-cannot-use-import-statement-outside-a-module</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 04:46:06 GMT</lastBuildDate><atom:link href="https://xcp-ng.org/forum/topic/4630.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 May 2021 20:20:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Wed, 26 May 2021 07:26:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/aqua-calc" aria-label="Profile: aqua-calc">@<bdi>aqua-calc</bdi></a> Make sure the repo is clean and there are no untracked files (<code>git status</code>).</p>
]]></description><link>https://xcp-ng.org/forum/post/39760</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39760</guid><dc:creator><![CDATA[julien-f]]></dc:creator><pubDate>Wed, 26 May 2021 07:26:01 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Wed, 03 Aug 2022 07:08:48 GMT]]></title><description><![CDATA[<p dir="auto">This error can happen in different cases depending on whether you're working with JavaScript on the server-side with Node.js , or client-side in the browser. There are several reasons behind "Cannot use import statement <a href="http://net-informations.com/js/err/import.htm" target="_blank" rel="noopener noreferrer nofollow ugc">outside a module</a>"  error, and the solution depends on how you call the module or script tag.</p>
<p dir="auto">Add type="module" inside the script tag</p>
<p dir="auto">When working with ECMAScript modules and JavaScript module import statements in the browser, you'll need to explicitly tell the browser that a script is module. To do this, you have to add type="module" onto any ‹script› tags that point to a JavaScript module. Once you do this you can import that module without issues.</p>
<pre><code>&lt;script type="module" src="./index.js"&gt;&lt;/script&gt;
</code></pre>
<p dir="auto">If you are working on Node.js or react applications and using import statements instead of require to load the modules, then ensure your package.json has a property "type": "module" as shown below.</p>
<pre><code>{
  // ...
  "type": "module",
  // ...
}
</code></pre>
]]></description><link>https://xcp-ng.org/forum/post/51809</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/51809</guid><dc:creator><![CDATA[ronaldgevern]]></dc:creator><pubDate>Wed, 03 Aug 2022 07:08:48 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Sun, 06 Jun 2021 07:35:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/jmrapin" aria-label="Profile: jmrapin">@<bdi>jmrapin</bdi></a> good job! after removing the untracked files, problem wasn't solved, and then i followed your instructions and it worked, thanks a lot!</p>
]]></description><link>https://xcp-ng.org/forum/post/39963</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39963</guid><dc:creator><![CDATA[iron_man]]></dc:creator><pubDate>Sun, 06 Jun 2021 07:35:07 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Thu, 27 May 2021 12:18:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/jmrapin" aria-label="Profile: jmrapin">@<bdi>jmrapin</bdi></a> Thank you!</p>
]]></description><link>https://xcp-ng.org/forum/post/39791</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39791</guid><dc:creator><![CDATA[aqua-calc]]></dc:creator><pubDate>Thu, 27 May 2021 12:18:55 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Thu, 27 May 2021 07:19:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/julien-f" aria-label="Profile: julien-f">@<bdi>julien-f</bdi></a> well spotted. Thanks!<br />
All good now.</p>
]]></description><link>https://xcp-ng.org/forum/post/39789</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39789</guid><dc:creator><![CDATA[jmrapin]]></dc:creator><pubDate>Thu, 27 May 2021 07:19:56 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Thu, 27 May 2021 07:10:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/jmrapin" aria-label="Profile: jmrapin">@<bdi>jmrapin</bdi></a> You still hav untracked <code>index.js</code> files in <code>xo-server/src</code>, please remove them and rebuild.</p>
]]></description><link>https://xcp-ng.org/forum/post/39787</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39787</guid><dc:creator><![CDATA[julien-f]]></dc:creator><pubDate>Thu, 27 May 2021 07:10:29 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Thu, 27 May 2021 05:20:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/aqua-calc" aria-label="Profile: aqua-calc">@<bdi>aqua-calc</bdi></a>, I have the same issue....<br />
building at commit level a204b6fb3f1236dc5f4519a734c4d5c8f99f9e9c<br />
and I am getting the same error. Cleaned all a did a fresh git pull --ff-only</p>
<p dir="auto">yarn run v1.22.5<br />
$ node dist/cli.mjs<br />
(node:3448) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.<br />
(Use <code>node --trace-warnings ...</code> to show where the warning was created)<br />
/root/xen-orchestra/packages/xo-server/dist/xapi/mixins/index.js:2<br />
import _gpu, * as __gpu from "./gpu";<br />
^^^^^^</p>
<p dir="auto">SyntaxError: Cannot use import statement outside a module<br />
etc...</p>
<p dir="auto">The yarn build command produces those files (there is something wrong somewhere, why does the build produces index.js when there is the index.mjs?)</p>
<p dir="auto">So</p>
<ol>
<li>delete /packages/xo-server/dist/xapi/mixins/index.js (rm index.js)</li>
<li>delete /packages/xo-server/dist/xapi/mixins/index.js.map (rm index.js.map)</li>
<li>remove the import and export statements referencing index.js from file /packages/xo-server/dist/xapi/mixins/index.mjs (nano index.mjs)</li>
</ol>
<p dir="auto">and did the same as above for /packages/xo-server/dist/api/index.js<br />
and same for /packages/xo-server/dist/xo-mixins/index.js</p>
<p dir="auto">And then yarn start and it starts and orchestra is fine as far as I can see.</p>
<p dir="auto">Not sure if that's the best but it got me going . Hope this helps someone.</p>
]]></description><link>https://xcp-ng.org/forum/post/39783</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39783</guid><dc:creator><![CDATA[jmrapin]]></dc:creator><pubDate>Thu, 27 May 2021 05:20:03 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Thu, 27 May 2021 01:26:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/julien-f" aria-label="Profile: julien-f">@<bdi>julien-f</bdi></a> I did fresh install, with config exported from the original xenorchestra server and then imported into the new server</p>
]]></description><link>https://xcp-ng.org/forum/post/39782</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39782</guid><dc:creator><![CDATA[aqua-calc]]></dc:creator><pubDate>Thu, 27 May 2021 01:26:51 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Wed, 26 May 2021 07:26:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/aqua-calc" aria-label="Profile: aqua-calc">@<bdi>aqua-calc</bdi></a> Make sure the repo is clean and there are no untracked files (<code>git status</code>).</p>
]]></description><link>https://xcp-ng.org/forum/post/39760</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39760</guid><dc:creator><![CDATA[julien-f]]></dc:creator><pubDate>Wed, 26 May 2021 07:26:01 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Tue, 25 May 2021 21:06:49 GMT]]></title><description><![CDATA[<p dir="auto">Then I don't know. <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/julien-f" aria-label="Profile: julien-f">@<bdi>julien-f</bdi></a> might be around tomorrow to check if it rings any bell.</p>
<p dir="auto">edit: as usual, double check you are on latest commit from <code>master</code>.</p>
]]></description><link>https://xcp-ng.org/forum/post/39751</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39751</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Tue, 25 May 2021 21:06:49 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Tue, 25 May 2021 21:03:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/olivierlambert" aria-label="Profile: olivierlambert">@<bdi>olivierlambert</bdi></a> Still getting the same error:</p>
<pre><code>root@xenorchestra:/opt/xen-orchestra/packages/xo-server# yarn start
yarn run v1.22.5
$ node dist/cli.mjs
(node:3490) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/opt/xen-orchestra/packages/xo-server/dist/xapi/mixins/index.js:2
import _gpu, * as __gpu from "./gpu";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:984:16)
    at Module._compile (internal/modules/cjs/loader.js:1032:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at ModuleWrap.&lt;anonymous&gt; (internal/modules/esm/translators.js:199:29)
    at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
    at async Loader.import (internal/modules/esm/loader.js:177:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
</code></pre>
]]></description><link>https://xcp-ng.org/forum/post/39750</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39750</guid><dc:creator><![CDATA[aqua-calc]]></dc:creator><pubDate>Tue, 25 May 2021 21:03:41 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Tue, 25 May 2021 20:41:33 GMT]]></title><description><![CDATA[<p dir="auto"><code>rm -rf node_modules</code>?</p>
]]></description><link>https://xcp-ng.org/forum/post/39749</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39749</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Tue, 25 May 2021 20:41:33 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Tue, 25 May 2021 20:40:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/olivierlambert" aria-label="Profile: olivierlambert">@<bdi>olivierlambert</bdi></a> Remove how?</p>
]]></description><link>https://xcp-ng.org/forum/post/39748</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39748</guid><dc:creator><![CDATA[aqua-calc]]></dc:creator><pubDate>Tue, 25 May 2021 20:40:31 GMT</pubDate></item><item><title><![CDATA[Reply to SyntaxError: Cannot use import statement outside a module on Tue, 25 May 2021 20:39:05 GMT]]></title><description><![CDATA[<p dir="auto">Be sure to remove your node_modules and rebuild after you updated to the latest Node LTS version.</p>
]]></description><link>https://xcp-ng.org/forum/post/39747</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/39747</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Tue, 25 May 2021 20:39:05 GMT</pubDate></item></channel></rss>