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

import toml using import statement in ts but failed #55

Open
one0oneChen opened this issue Jan 14, 2024 · 2 comments
Open

import toml using import statement in ts but failed #55

one0oneChen opened this issue Jan 14, 2024 · 2 comments

Comments

@one0oneChen
Copy link

Hello, everyone. I tried to import toml using import statement in ts but failed, can someone help me

import toml from '@iarna/toml';
...
configdata = toml.parse(configstr)
hmr.ts:204  ReferenceError: global is not defined
    at node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js (create-date.js:3:18)
    at __require (chunk-Y2F7D3TJ.js?v=4804ad59:3:50)
    at node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js (toml-parser.js:26:20)
    at __require (chunk-Y2F7D3TJ.js?v=4804ad59:3:50)
    at node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js (parse-string.js:4:20)
    at __require (chunk-Y2F7D3TJ.js?v=4804ad59:3:50)
    at node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js (parse.js:2:18)
    at __require (chunk-Y2F7D3TJ.js?v=4804ad59:3:50)
    at node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js (toml.js:2:17)
    at __require (chunk-Y2F7D3TJ.js?v=4804ad59:3:50)
warnFailedUpdate @ hmr.ts:204
fetchUpdate @ hmr.ts:237
await in fetchUpdate(异步)
(anonymous) @ client.ts:182
handleMessage @ client.ts:180
(anonymous) @ client.ts:92
显示 5 更多框架
显示简略信息
hmr.ts:206  [hmr] Failed to reload /src/components/Index.vue. This could be due to syntax errors or importing non-existent modules. (see errors above)
@khalilou88
Copy link

how about this: import * as toml from '@iarna/toml';?

@SnowWarri0r
Copy link

@one0oneChen if you are using vite,global is not defined by default,you need to define it manually.you can see this post: https://stackoverflow.com/questions/72114775/vite-global-is-not-defined

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

No branches or pull requests

3 participants