Why my repl.it only run "index.js" file and can not run other name file?

Question:
I have several file in replt.it
only when i put the code into “index.js” file then the file will successfully run and generate the output.
if i let repl.it to run other name file, its just doesn’t work

Repl link/Link to where the bug appears:

Screenshots, links, or other helpful context:

code snippet

In replit, the file it runs when you click the run button is determined by the entrypoint or run variable in .replit file.
In your repl here your .replit entrypoint is index.js, which when you click run it runs index.js, you can change that by changing the entrypoint variable.

在replit裡,.replit檔案是決定你按綠色執行按鈕時它運行的程式。在你的.replit檔案裡你的執行文件(entrypoint)是index.js,所以它只會運行index.js。你可以透過更改entrypoint變數去改變你點擊執行時它運行的檔案

please provide link to your repl next time, thank you.
下次可以提供你repl的連結

(off topic, but I haven’t typed any chinese on replit for sooooo long fr lol)

4 Likes

thank you, you’re a real one for the bilingual answers :+1:

1 Like

thank you sooooo much!! @TaokyleYT you just gave my answer!!

i did what you told me to change the file name in .replit file
and its workssss

my another question is if my file name is in chinese, it seems doesn’t run as well.
so it only accept english name in the file name in repl.it, isn’t it?

here is my repl.it link
https://replit.com/@clairehuang7777/Hello-World#擲骰子比大小%20(assignment).js

https://replit.com/@clairehuang7777/Hello-World#.replit

after researching for a bit I found this github issue describes chinese files or folders causing error, in short node js misinterpreted your filename as to 1 byte, but any text encoding method that includes chinese is 2 byte long, for example (guobao, unicode), this caused your text to be unexpectedly seperated and causing error.

Try your best not to use any character except those in the ascii table as your filename, if you need to, comment what it does inside the file and/or rename it to as descriptive name.

3 Likes

sure no problem! thank you for the detailed description :slight_smile:

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