How can I configure my run button to execute "npm run dev" in the shell?

Repl in question:
My repl is a chat service based off of node.js, and using

I’ve tried many things to get it to work, such as including “#!/bin/bash” on the top line of a file (which I am using to execute “npm run dev”).

I’ve asked ChatGPT already. Which didn’t help much but at least it tried.

Currently, my .replit file looks like this:

language = "nodejs"
run = "bash"
entrypoint = ""
hidden = [".config", "package-lock.json"]


pattern = "**/{*.js,*.jsx,*.ts,*.tsx,*.json}"

start = "typescript-language-server --stdio"

support = true

transport = "localhost:0"
startCommand = ["dap-node"]

command = "initialize"
type = "request"

clientID = "replit"
clientName = ""
columnsStartAt1 = true
linesStartAt1 = true
locale = "en-us"
pathFormat = "path"
supportsInvalidatedEvent = true
supportsProgressReporting = true
supportsRunInTerminalRequest = true
supportsVariablePaging = true
supportsVariableType = true

command = "launch"
type = "request"

console = "externalTerminal"
cwd = "."
pauseForSourceMap = false
program = "./index.js"
request = "launch"
sourceMaps = true
stopOnEntry = false
type = "pwa-node"

language = "nodejs"

packageSearch = true
guessImports = true
enabledForHosting = false

command = ["prybar-nodejs", "-q", "--ps1", "\u0001\u001B[33m\u0002\u0001\u001B[00m\u0002 ", "-i"]

language = "nodejs"

channel = "stable-22_11"

XDG_CONFIG_HOME = "/home/runner/$REPL_SLUG/.config"
PATH = "/home/runner/$REPL_SLUG/.config/npm/node_global/bin:/home/runner/$REPL_SLUG/node_modules/.bin"
npm_config_prefix = "/home/runner/$REPL_SLUG/.config/npm/node_global"

requiredFiles = [".replit", "replit.nix", ".config", "package.json", "package-lock.json"]

regex = 'Error \[ERR_REQUIRE_ESM\]'
message = "We see that you are using require(...) inside your code. We currently do not support this syntax. Please use 'import' instead when using external modules. ("

#run = ["sh", "-c", "bash"]

1 Like

Does setting the run command to npm run dev not work?

I have tried that. But nothing changes.

Welcome @jkkgvnrb5t!

Setting the run command in your .replit file from run = "bash" to run = "npm run dev" should configure the run button to execute that instead.

I have tried that, but nothing changed.

What happens when you do that specifically?

Hey @jkkgvnrb5t, welcome to the community!

Try setting run to "node your_init_file.js".

Also, is there a specific reason why you have to use shell commands instead of Javascript files?

I’m trying to get this code to run in the shell, as that’s where I am able to start the chat.

The reason I am doing this is because that’s where the “npm run dev” command works in my repl. Doing so in the console doesn’t work at all, I just get errors.

Though I did try setting the run command to run my server.js file, and now I’m getting this error inside the console. The original site/process appears to not want to stop running.

I believe your code needs multiple files to work

You can start by going into your package.json file and in under scripts, add "dev" = "node file1.js && node file2.js && node file3.js...".

Then change run in your .replit file into "npm run dev".


I didn’t change anything and it just started working, which is kind of weird but I’m not complaining.

Thank you for your help though! Have a good day.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.