Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build fails under node 21 #24

Open
rcarmo opened this issue Apr 28, 2024 · 7 comments
Open

build fails under node 21 #24

rcarmo opened this issue Apr 28, 2024 · 7 comments

Comments

@rcarmo
Copy link

rcarmo commented Apr 28, 2024

I get an error message stating that the build configuration is broken. I have the following Node versions:

node -v
v21.7.3
npm -v
10.5.0

Log:

% npm run build                                                        

> [email protected] build
> NODE_ENV=production npx rollup --config openscad-worker.rollup.config.js && webpack --mode=production

(node:96287) 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)
[!] RollupError: Node tried to load your configuration file as CommonJS even though it is likely an ES module. To resolve this, change the extension of your configuration to ".mjs", set "type": "module" in your package.json file or pass the "--bundleConfigAsCjs" flag.

Original error: Cannot use import statement outside a module
https://rollupjs.org/command-line-interface/#bundleconfigascjs
/Users/rcarmo/Build/openscad-playground/openscad-worker.rollup.config.js:2
import typescript from 'rollup-plugin-typescript2';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:128:18)
    at wrapSafe (node:internal/modules/cjs/loader:1279:20)
    at Module._compile (node:internal/modules/cjs/loader:1331:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12)
    at cjsLoader (node:internal/modules/esm/translators:366:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:315:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
  [cause] /Users/rcarmo/Build/openscad-playground/openscad-worker.rollup.config.js:2
  import typescript from 'rollup-plugin-typescript2';
  ^^^^^^
  
  SyntaxError: Cannot use import statement outside a module
      at internalCompileFunction (node:internal/vm:128:18)
      at wrapSafe (node:internal/modules/cjs/loader:1279:20)
      at Module._compile (node:internal/modules/cjs/loader:1331:27)
      at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
      at Module.load (node:internal/modules/cjs/loader:1205:32)
      at Module._load (node:internal/modules/cjs/loader:1021:12)
      at cjsLoader (node:internal/modules/esm/translators:366:17)
      at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:315:7)
      at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
      at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)

@JaxTheWolf
Copy link

I keep getting the same error, trying multiple versions of Node (21, 20, 18, haven't tried other).
I was planning on dockerising this project for myself (and maybe my friends).

@ochafik
Copy link
Collaborator

ochafik commented May 30, 2024

Sorry just seeing this. Building thing successfully here (on Mac) w/ Node v22.2.0 (make public && npm run build)

@JaxTheWolf
Copy link

JaxTheWolf commented May 30, 2024

FROM node:18-alpine

RUN apk update
RUN apk add wget make bash git zip 

RUN mkdir /src

COPY src /src

WORKDIR /src

RUN make public
RUN npm run start:prod

This is my Dockerfile. I think I got all the dependencies right. Fails with the same error as above.

@ochafik
Copy link
Collaborator

ochafik commented May 30, 2024

@JaxTheWolf weird, that Dockerfile works for me, in the current main branch, just modified COPY . /src and ran docker build . from the repo root.

@JaxTheWolf
Copy link

JaxTheWolf commented May 30, 2024

@JaxTheWolf weird, that Dockerfile works for me, in the current main branch, just modified COPY . /src and ran docker build . from the repo root.

Hm, could you try running it in a Linux VM? I would try Mac OS, but that's a bit more hassle than it's worth :D

@ochafik
Copy link
Collaborator

ochafik commented May 30, 2024

Ah sorry i think my copy ‘.’ without cleaning first means it didn’t try and build everything from the container. Will try again shortly

Edit: it's not that, still works. I'll try on Linux when I get my hands on a box or VM (or will just setup some github workflows).

@scouzi1966
Copy link

Error is a bit misleading. Try installing rollup-plugin-typescript2. "npm install rollup-plugin-typescript2". This worked for me on a fairly up to dat ubuntu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants