I've created a brand new project with npm init vite bar -- --template vue
. I've done an npm install web3
and I can see my package-lock.json
includes this package. My node_modules
directory also includes the web3
modules.
So then I added this line to main.js
:
import { createApp } from 'vue'
import App from './App.vue'
import Web3 from 'web3' <-- This line
createApp(App).mount('#app')
And I get the following error:
I don't understand what is going on here. I'm fairly new to using npm
so I'm not super sure what to Google. The errors are coming from node_modules/web3/lib/index.js
, node_modules/web3-core/lib/index.js
, node_modules/web3-core-requestmanager/lib/index.js
, and finally node_modules/util/util.js
. I suspect it has to do with one of these:
- I'm using Vue 3
- I'm using Vue 3 Composition API
- I'm using Vue 3 Composition API SFC
<script setup>
tag (but I imported it inmain.js
so I don't think it is this one) web3js
is in Typescript and my Vue3 project is not configured for Typescript
But as I am fairly new to JavaScript and Vue and Web3 I am not sure how to focus my Googling on this error. My background is Python, Go, Terraform. Basically the back end of the back end. Front end JavaScript is new to me.
How do I go about resolving this issue?