Hi all,
I am now working on my project using typescript, nextjs and moralis. Everything is working fine until I compile the project.
My code is farley simple like below:
const getTokenInfo = async () => {
let addr = selectedTokenRef.current!.value
if (addr != ""){
try{
const options: MoralisGetTokenMetadataOptionType = { chain: "bsc testnet", addresses: [addr.toLowerCase()] };
const tokenMetadata = await Moralis.Web3API.token.getTokenMetadata(options);
console.log(tokenMetadata[0])
let balance = await getTokenBalance(tokenMetadata[0].address)
let metadata = {...tokenMetadata[0], balance: balance}
setSelectedToken(metadata)
}catch(e){
console.log(e)
}
} else {
alert("Input token address")
}
}
when doing build process, It shows below error msg to me:
> next build
info - Loaded env from /Users/macbookpro4eric/Projects/blockchain/project32_safetrate_ts/.env
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
Failed to compile.
./node_modules/moralis/types/generated/web3api.d.ts:1593:10
Type error: Unexpected keyword or identifier.
1591 | }
1592 |
> 1593 | static eth-defi: {
| ^
1594 | getPairReserves: (options: operations["getPairReserves"]["parameters"]["query"] & operations["getPairReserves"]["parameters"]["path"]) => Promise<operations["getPairReserves"]["responses"]["200"]["content"]["application/json"]>;
1595 | getPairAddress: (options: operations["getPairAddress"]["parameters"]["query"] & operations["getPairAddress"]["parameters"]["path"]) => Promise<operations["getPairAddress"]["responses"]["200"]["content"]["application/json"]>;
1596 | }
info - Checking validity of types .npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/macbookpro4eric/.npm/_logs/2021-10-05T07_13_08_133Z-debug.log
I also tried to deploy the application onto vercel. And it also shows similar error like below:
16:04:46.129
info - Checking validity of types...
16:04:51.052
Failed to compile.
16:04:51.053
16:04:51.053
./components/app/SafeTrade.tsx:82:61
16:04:51.054
Type error: Property 'token' does not exist on type 'typeof Web3API'.
16:04:51.054
16:04:51.054
e[0m e[90m 80 | e[39m e[36mtrye[39m{e[0m
16:04:51.054
e[0m e[90m 81 | e[39m
It will be very appreciated if anybody could give me a hint about where do I do wrong.