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

[dev-2.0] npm run build seems failed with assert #7451

Closed
1 of 17 tasks
asukaminato0721 opened this issue Dec 27, 2024 · 2 comments
Closed
1 of 17 tasks

[dev-2.0] npm run build seems failed with assert #7451

asukaminato0721 opened this issue Dec 27, 2024 · 2 comments
Labels

Comments

@asukaminato0721
Copy link
Contributor

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

1.9.4

Web browser and version

No response

Operating system

linux

Steps to reproduce this

Steps:

  1. run npm run build

Snippet:

> npm run build

> p5@1.9.4 build
> rollup -c

[!] SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:338:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:103:18)
    at ModuleLoader.#translate (node:internal/modules/esm/loader:437:12)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:484:27)
    at ModuleJob._link (node:internal/modules/esm/module_job:115:19)

seems caused by

import pkg from './package.json' assert { type: 'json' };

in rollup.config.mjs

I find that change to

import { readFileSync } from 'fs';
const pkg = JSON.parse(readFileSync('./package.json'));

can successfully build it.

@asukaminato0721 asukaminato0721 changed the title npm run build seems failed with assert [dev-2.0] npm run build seems failed with assert Dec 28, 2024
@Rishab87
Copy link
Contributor

Rishab87 commented Dec 28, 2024

I also faced this issue, its because of the new syntax and assert keyword not being present in latest node version, you can use an older npm version like 21, just install nvm and write nvm use 21

@limzykenneth
Copy link
Member

Will change to use import attributes using with keyword instead.

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

No branches or pull requests

3 participants