dreev
April 6, 2023, 4:56pm
1
GhostWriter still thinks I should use a .env file but neither the UI nor the shell lets me create one, saying that .env is deprecated (more than deprecated, apparently).
But there’s no Secrets in the Tools section. Googling and other forum posts suggest that only certain kinds of replits allow secrets (environment variables) but I can’t figure out how to change what kind of replit my replit is.
Help?
1 Like
Welcome to Ask!
Can you please provide a link to your repl so we can better help you troubleshoot this?
1 Like
if you open a new tab in the IDE then type in “secrets” it’ll pop up
1 Like
Not on all repls miniboss. (Which is why I asked for a repl link)
2 Likes
wdym for me that always works…
1 Like
At the very least IIRC, you can’t in HTML/CSS/JS
repls.
2 Likes
dreev
April 6, 2023, 5:01pm
8
1 Like
you should copy this code to a node repl
1 Like
Hi @dreev , welcome to the community!
HTML/JS/CSS is the only “special” kind of Repl. Things that apply for “all” Repls do not apply, and things that apply for it do not apply to others. Like the HTML/JS/CSS Repls are not actually hosted in the Repl, and they also do not have access to secrets or Replit DB. This is because they are frontend, and if they had access to secrets or DB, anyone who used your website could view / modify them!
If you want to use these features, I recommend a backend like Python Flask or NodeJS Express, which will let you safely use these features.
3 Likes
HTML/CSS/JS
repls do not support Secrets
, I recommend using Flask
or Node.js
.
3 Likes
no the code IS a node repl but it’s just got .replit
and replit.nix
configured for html
1 Like
dreev
April 6, 2023, 5:03pm
13
Hmm, I imported this repl from GitHub and apparently… did it wrong? Should I delete it and import it fresh in a different way?
2 Likes
hmm no I would do this:
change the .replit
file to:
entrypoint = "index.js"
hidden = [".config", "package-lock.json"]
[interpreter]
command = [
"prybar-nodejs",
"-q",
"--ps1",
"\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
"-i"
]
[[hints]]
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. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)"
[nix]
channel = "stable-22_11"
[env]
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"
[gitHubImport]
requiredFiles = [".replit", "replit.nix", ".config", "package.json", "package-lock.json"]
[packager]
language = "nodejs"
[packager.features]
packageSearch = true
guessImports = true
enabledForHosting = false
[unitTest]
language = "nodejs"
[debugger]
support = true
[debugger.interactive]
transport = "localhost:0"
startCommand = [ "dap-node" ]
[debugger.interactive.initializeMessage]
command = "initialize"
type = "request"
[debugger.interactive.initializeMessage.arguments]
clientID = "replit"
clientName = "replit.com"
columnsStartAt1 = true
linesStartAt1 = true
locale = "en-us"
pathFormat = "path"
supportsInvalidatedEvent = true
supportsProgressReporting = true
supportsRunInTerminalRequest = true
supportsVariablePaging = true
supportsVariableType = true
[debugger.interactive.launchMessage]
command = "launch"
type = "request"
[debugger.interactive.launchMessage.arguments]
args = []
console = "externalTerminal"
cwd = "."
environment = []
pauseForSourceMap = false
program = "./index.js"
request = "launch"
sourceMaps = true
stopOnEntry = false
type = "pwa-node"
[languages]
[languages.javascript]
pattern = "**/{*.js,*.jsx,*.ts,*.tsx}"
[languages.javascript.languageServer]
start = "typescript-language-server --stdio"
[deployment]
run = ["sh", "-c", "node index.js"]
and the replit.nix
file to
{ pkgs }: {
deps = [
pkgs.nodejs-18_x
pkgs.nodePackages.typescript-language-server
pkgs.yarn
pkgs.replitPackages.jest
];
}
dreev
April 6, 2023, 5:08pm
15
Done. But… no change, even after reloading the repl.
1 Like
interesting hmm I don’t know
oh wait I found the problem change .replit
to:
entrypoint = "server.js"
hidden = [".config", "package-lock.json"]
[interpreter]
command = [
"prybar-nodejs",
"-q",
"--ps1",
"\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
"-i"
]
[[hints]]
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. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)"
[nix]
channel = "stable-22_11"
[env]
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"
[gitHubImport]
requiredFiles = [".replit", "replit.nix", ".config", "package.json", "package-lock.json"]
[packager]
language = "nodejs"
[packager.features]
packageSearch = true
guessImports = true
enabledForHosting = false
[unitTest]
language = "nodejs"
[debugger]
support = true
[debugger.interactive]
transport = "localhost:0"
startCommand = [ "dap-node" ]
[debugger.interactive.initializeMessage]
command = "initialize"
type = "request"
[debugger.interactive.initializeMessage.arguments]
clientID = "replit"
clientName = "replit.com"
columnsStartAt1 = true
linesStartAt1 = true
locale = "en-us"
pathFormat = "path"
supportsInvalidatedEvent = true
supportsProgressReporting = true
supportsRunInTerminalRequest = true
supportsVariablePaging = true
supportsVariableType = true
[debugger.interactive.launchMessage]
command = "launch"
type = "request"
[debugger.interactive.launchMessage.arguments]
args = []
console = "externalTerminal"
cwd = "."
environment = []
pauseForSourceMap = false
program = "./server.js"
request = "launch"
sourceMaps = true
stopOnEntry = false
type = "pwa-node"
[languages]
[languages.javascript]
pattern = "**/{*.js,*.jsx,*.ts,*.tsx}"
[languages.javascript.languageServer]
start = "typescript-language-server --stdio"
[deployment]
run = ["sh", "-c", "node server.js"]
1 Like
Could it be because their main file is server.js
? (Also, changing replit.nix
and .replit
wouldn’t unlock secrets I don’t think.)
2 Likes
dreev
April 6, 2023, 5:18pm
19
Doh, I just tried deleting the repl and recreating it as a Node.js repl, with the intention to then import again from GitHub. But now it’s completely borked. The repl exists in my gallery of repls but when I try to load it it just silently fails and goes back to the replit homepage. Argh.
[more beating my head against walls ensues]
Ok, the empty replit is loading in the IDE now and I’m saying to import from GitHub. It gives me a scary warning about passing along a git command from the shell which I don’t understand but am agreeing to. Now it’s just hanging for several minutes saying it’s connecting to GitHub:
2 Likes
dreev
April 6, 2023, 5:37pm
20
Update! It wasn’t hung, apparently. It just took like 10 full minutes to import this itsy bitsy repo from GitHub. Weird.
And now I can add my Secrets!
But the saga continues. When I click Run I see this in the console:
Run isn’t configured. Try adding a .replit and configuring it https://docs.replit.com/programming-ide/configuring-run-button
This is clearly not meant to be this hard and I’d still be grateful to understand what has gone wrong with something that should be simple – taking an existing functional Node app (it works on Glitch and Render.com fine!) and importing it into Replit and running it.