usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.62k stars 1.28k forks source link

Cannot import builtin module (node-fetch, axios) #2946

Open dglav opened 2 months ago

dglav commented 2 months ago

I have checked the following:

Describe the bug

When importing "node-fetch" in my pre-request script, the return value is null.

I've tried adding node-fetch to the whitelist and installing node-fetch via npm in a package.json file in the same directory, but to no avail.

.bru file to reproduce the bug

const fetch = require('node-fetch')

console.log('pre-request script') 
console.log(fetch) // null

bruno.json file:

{
  "version": "1",
  "name": "PaaS API",
  "type": "collection",
  "ignore": ["node_modules", ".git"],
  "scripts": {
    "moduleWhitelist": ["node-fetch", "axios"],
    "filesystemAccess": {
      "allow": true
    }
  }
}

Screenshots/Live demo link

image
roband7 commented 2 months ago

Looks somewhat similar to what I reported in https://github.com/usebruno/bruno/issues/2907 Are you in safe mode, and does it work in developer mode?

dglav commented 2 months ago

@roband7 Unfortunately I am already using developer mode and the issue is still present.

IRlyDontKnow commented 2 months ago

I've got the same issue. Just installed newest version of bruno and when i'm trying to import axios, it returns null.

osadi commented 2 months ago

Also received null from any require made in Pre Request scripts. Switching to Safe Mode from Developer Mode gave me working imports.

Bruno v1.28.0
electron    : 31.2.1
chrome  : 126.0.6478.127
node    : 20.15.0
v8  : 12.6.228.21-electron.
dglav commented 1 month ago

Also received null from any require made in Pre Request scripts. Switching to Safe Mode from Developer Mode gave me working imports.

Bruno v1.28.0
electron  : 31.2.1
chrome    : 126.0.6478.127
node  : 20.15.0
v8    : 12.6.228.21-electron.

When I use Safe Mode I get the following error in the response panel:

Error invoking remote method 'send-http-request': Error: Error: Cannot find module node-fetch