Skip to content

After update to 0.28.2, run asbuild fail with error: ReferenceError: fetch is not defined #2929

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

Closed
leeho0108 opened this issue Jun 4, 2025 · 4 comments
Labels

Comments

@leeho0108
Copy link

Bug description

env:
node: v22.16.0
assemblyscript: 0.28.2

asbuild fail with blow error:

ReferenceError: fetch is not defined
at (/{PATH_TO_PROJECT}/node_modules/assemblyscript/node_modules/as-float/index.js:3:45)

I use 0.27.36 before upgrade, and everything just work fine.

Steps to reproduce

reproduce step:
1.create empty project
2.run: npm init
3.run: npm i --save-dev [email protected]
4.run: npx asconfig .
5.open pacakge.json, mouse hover on scripts/asbuild, then click "Run Script" button on popup.
6.build fail with error

7.if open a terminal, then manual input "npm run asbuild",then press entry, this way will build success...

AssemblyScript version

v0.28.2

@leeho0108 leeho0108 added the bug label Jun 4, 2025
@CountBleck
Copy link
Member

You're saying it works when you use a terminal? If that's the case, I think VSCode is running the script with the wrong Node version...

@mattjohnsonpint
Copy link
Contributor

I tried to repro this, without success. It worked in all cases. I tried on both MacOS and Windows, and Node 18, 20, and 22. Also in the repro on step 4, did you mean npx asinit . ? I don't know what asconfig is.

@CountBleck
Copy link
Member

CountBleck commented Jun 4, 2025

It should fail for anything below Node 18.1.0, and the engines requirement for AS 0.28 should prevent it from being installed for anything below Node 20 (unfortunately we screwed up and released the change in 0.27.37, but installing with [email protected] should prevent 0.27.37 from being installed anyway...).

@leeho0108 Are you using a Node version manager like nvm, fnm, or volta? If so, VSCode might be using your system Node.js installation instead of the one selected by your version manager. In that case, you might need to configure VSCode to use your version manager's selected version. You should also update your system Node.js installation (Node v18 is no longer supported by Node.js themselves).

@leeho0108
Copy link
Author

I am using nvm for node.
I run script by click "Run Script" for codes: "showNodeVersion":"node -v"
and it prints "v16.20.0"
then i try remove files

rm -rf /usr/local/bin/npm
rm -rf /usr/local/bin/node

and rerun scripts, it prints the right version: "v22.16.0"
and the build script execute success!

It's my bad, it is not as's bug, sorry for this

Thank you, guys.
Best regards

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