I'm blogging in Next.js.If I write Github's personal access token directly in the code, I have trouble giving the code to Github, so I try to write the access token I don't want to post in an external file and ignore it with .gitignore
, but it doesn't work.
token.ts
in the root folder of next.js and const accessToken="access token";
accessToken from '../token'
, but I got a red ~~ and got an error.Token.ts side error with token
'token.ts'cannot be compiled under' -- isolatedModules' cause it is considered a global script file.Add an import, export, or import' export {}' statement to make it a module
Read side error
File'/Users/username/Desktop/mac_work/nodejs/blog/my-blog/token.ts' is not a module.
File to load token.ts
//export.
export const accessToken="token";
On the file side you want to load
//{}.
import {accessToken} from '../token'
© 2024 OneMinuteCode. All rights reserved.