bruno icon indicating copy to clipboard operation
bruno copied to clipboard

Cannot import builtin module (node-fetch, axios)

Open dglav opened this issue 1 year ago • 5 comments

I have checked the following:

  • [X] I use the newest version of bruno.
  • [X] I've searched existing issues and found nothing related to my issue.

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

dglav avatar Aug 28 '24 04:08 dglav

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?

roband7 avatar Aug 28 '24 13:08 roband7

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

dglav avatar Aug 29 '24 01:08 dglav

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

IRlyDontKnow avatar Aug 31 '24 09:08 IRlyDontKnow

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.

osadi avatar Sep 13 '24 05:09 osadi

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

dglav avatar Sep 26 '24 08:09 dglav