4

I created a new react-native project using

npx react-native init AwesomeTSProject --template react-native-template-typescript

Then I followed the steps metioned in the following url to install @solana/web3.js package https://solanacookbook.com/integrations/react-native.html#create-a-new-app

Then I gave this command to generate the build

npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

I am getting this error

error node_modules/@solana/web3.js/lib/index.native.js: Unexpected token name «n», expected punc «,» in file node_modules/@solana/web3.js/lib/index.native.js at 4276:32.
Error: Unexpected token name «n», expected punc «,» in file node_modules/@solana/web3.js/lib/index.native.js at 4276:32
    at minifyCode (/Users/username/Workspace/sampleproj/node_modules/metro-transform-worker/src/index.js:99:13)
    at transformJS (/Users/username/Workspace/sampleproj/node_modules/metro-transform-worker/src/index.js:317:28)
    at transformJSWithBabel (/Users/username/Workspace/sampleproj/node_modules/metro-transform-worker/src/index.js:408:16)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.transform (/Users/username/Workspace/sampleproj/node_modules/metro-transform-worker/src/index.js:569:12)

Can anyone help me out??

3

1 Answer 1

2

The n token that the bundle step is failing on is part of a JavaScript bigint literal. These are literals of the form 10000n. At a certain point, @solana/web3.js began to admit code made up of bigint literals.

Your version of React Native does not support bigint literals. Check out the minimum requirements in the README of @solana/web3.js.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.