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

Error using in Vue3 #200

Open
JakobMiksch opened this issue Nov 2, 2023 · 3 comments
Open

Error using in Vue3 #200

JakobMiksch opened this issue Nov 2, 2023 · 3 comments

Comments

@JakobMiksch
Copy link

When I use shpjs in a vanilla Vue3 app, I get this error:

image

How to reproduce:

Create a new Vue3 app

npm create vue@latest

install dependencies:

npm install 
npm install shpjs --save

In App.vue import

import shp from "shpjs"

then the error from above will appear.

@JakobMiksch
Copy link
Author

workaround:

add this to vite.config.ts (taken from here):

 export default defineConfig({
    define: {
      global: {},
    },
  })

also install buffer as dev dependency:

npm i -D buffer
# or
yarn add -D buffer

@Preyou
Copy link

Preyou commented Nov 6, 2023

我是这么解决的

import { Buffer } from 'buffer'
window.Buffer = Buffer

window.global = globalThis

@sqlAIJava
Copy link

我就是这么解决的

import { Buffer } from 'buffer'
window.Buffer = Buffer

window.global = globalThis

在main.ts中使用即可

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