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

Implement nodejs module "vm" #479

Closed
bilalmetla opened this issue Jul 9, 2022 · 5 comments
Closed

Implement nodejs module "vm" #479

bilalmetla opened this issue Jul 9, 2022 · 5 comments
Labels
node.js Compatibility with Node.js APIs

Comments

@bilalmetla
Copy link

I have an application written in the nodejs and working fine. Now I tried to run this with bun.
command:
bun run start.js
but getting error as in the screen short.
Screenshot 2022-07-09 at 12 54 07 PM

I have macos.
Screenshot 2022-07-09 at 12 55 42 PM

I need some guid to fix this issue..

@FinnRG
Copy link
Collaborator

FinnRG commented Jul 9, 2022

Can you paste your package.json?

@FinnRG FinnRG added the bug Something isn't working label Jul 9, 2022
@bilalmetla
Copy link
Author

package.json file

`
{
"name": "onestream-chat",
"version": "1.0.0",
"description": "its chat application",
"main": "ecosystem.config.js",
"scripts": {
"dev": "node ./start.js",
"localdev": "pm2 restart ecosystem.config.js --env localdev",
"development": "pm2 restart ecosystem.config.js --env development",
"production": "pm2 restart ecosystem.config.js --env production",
"test": "echo "Error: no test specified" && exit 1"
},
"dependencies": {
"@socket.io/redis-adapter": "^7.2.0",
"@socket.io/sticky": "^1.0.1",
"axios": "^0.27.2",
"consul": "^0.40.0",
"dank-twitch-irc": "^4.3.0",
"dayjs": "^1.11.3",
"dotenv": "^16.0.1",
"eventsource": "^2.0.2",
"express": "^4.18.1",
"fb": "^2.0.0",
"googleapis": "^104.0.0",
"ioredis": "^5.0.6",
"mysql2": "^2.3.3",
"pino": "^8.0.0",
"pino-pretty": "^8.0.0",
"pouchdb": "^7.3.0",
"redis": "^4.1.0",
"request": "^2.88.2",
"sequelize": "^6.21.2",
"socket.io": "^4.5.1",
"socket.io-client": "^4.5.1",
"uuid": "^8.3.2"
},
"devDependencies": {
"nodemon": "^2.0.16"
},
"author": "mbilal",
"license": "ISC"
}

`

@nhasdarjian
Copy link

nhasdarjian commented Jul 16, 2022

I am having the same error, also using Bun;
in my case it's being triggered by

  • { Script.m } = require("vm");

in esm.js in the esm module.

After a bit of reading the docs and issues on all the relevant GitHub pages,
I learned that "vm" is a Node.js built-in module that allows you to run code in sandbox mode.
Bun handles VM behavior using "vm-browserify", another Node module.

Any modules that depend on Node's vm feature ( esm, fast-redact ) ought to have this problem in Bun. I don't know much about what to do about it, but hopefully a dev can glean some insight from this.

@maximilianschmid
Copy link

maximilianschmid commented Jul 25, 2022

npm package 'fast-redact' causes this issue. Blocks bun from running our NodeJS server.js script.

error: Could not resolve: "vm". Maybe you need to "bun install"?

const { createContext, runInContext } = require('vm')
                                                ^

@xhyrom xhyrom changed the title error: Could not resolve: "vm" Implement nodejs module "vm" Jul 28, 2022
@xhyrom xhyrom added enhancement New feature or request node.js Compatibility with Node.js APIs polyfill and removed bug Something isn't working enhancement New feature or request labels Jul 28, 2022
@Electroid
Copy link
Contributor

We will implement this! Closing because this is a duplicate, tracking here: #401

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
node.js Compatibility with Node.js APIs
Projects
None yet
Development

No branches or pull requests

6 participants