Can you help me get this working on Repl.it?
I'm teaching myself to code and I've managed to put all my GitHub repos on Repl.it, except for this one.
https://replit.com/@acchang/ProjectToDoList
After I hit run, I'm told npm ERR! missing script: start
.
It's my first time using repl.it with a package using npm and webpack and other external libraries.
Can you tell me if it's possible, and if so, what am I doing wrong?
I managed to get it to work on GitHub pages: https://acchang.github.io/ProjectToDoList/
Voters
in your
package.json
you need to have "start" : "scriptname" of the script you want it to start as the first file to run, usually this problem doesn't appear because the default file isserver.js
which npm will run automatically. Either change the package.json file or create a server.js file.Here is some stuff that might help: https://stackoverflow.com/questions/31976722/start-script-missing-error-when-running-npm-start
@InvisibleOne Thanks! I played around with package.json and the stackoverflow link you sent. It helped orient me to the problem, but I still haven't solved it yet.
It looks like the lack of a "start" is the issue. I don't have a script.js, but I do have an index.js that is my first file to run.
I used to have a script.js, but that was when I was just dealing with a single file each for js, css and html.
Now that I'm using webpack, my first file is index.js and that's located in /src. I can't seem to point "start" to
index.js
. Am I going in the right direction?I tested a bunch of suggested solutions fron StackOverflow:
Added: "start": "node /src/index.js" to package.json
Error: Cannot find module '/src/index.js'
Since index.js is the first file, I renamed it to server.js, I get:
Since I no longer use script.js, I took out from package.json "main": "script.js",
I added to package.json "start": "node your-script.js",
Error: Cannot find module '/home/runner/ProjectToDoList/your-script.js'
Added "start": "node index.js",
Error: Cannot find module '/home/runner/ProjectToDoList/index.js'
Added:
"prestart": "npm install", "start": "http-server -a localhost -p 8000 -c-1"
,Added: "test": "make test", "start": "node index.js"
Maybe it's becuase you main script is

script.js
in thepackage.json
and you don't have ascript.js
file.@acchang
@InvisibleOne ahh, thanks. I tried switching to
"main": "index.js",
but it still didn't work. I tried adding"start": "node index.js",
then `"start": "node /src/index.js", but I also got "module not found."Is there a way to point the start to the proper js file? I tried making a
server.js
in the main space, but then I realized I couldn't just importindex.js
there because I'd have to makeindex.js
into some sort of function, no?try setting
"main" : "src/index.js"
and"start":"node src/index.js"
@acchang@InvisibleOne Thanks! Getting closer... I added
"main": "src/index.js",
and"start": "node src/index.js",
and got error message:I changed both
index.js
toindex.mjs
and gotError: Cannot find module '/home/runner/ProjectToDoList/src/index.mjs'
So I did the other option and added
"type": "module"
to package.json. This got past one hurdle, but another emerged:/home/runner/ProjectToDoList/src/createTaskInput
does exist.I don't recognize the code,
internalBinding('errors').triggerUncaughtException
.Do I need to build a
server.js
file and if so, what goes in there?Also, just out of curiosity, it makes sense to me why you suggested these changes, they are input points.
But it works with all these mistakes in GitHub pages.
Is that because GitHub pages is more forgiving?
Should I go back into my repo and make the changes in
package.json
start
andmain
too?I was able to get this online with a little digging and another generous soul on a Discord server. (Not mentioning them by name just in case they'd rather stay anonymous.)
In the process, I got a better idea of how this all works.
Because this code relies on webpack, it uses node. Because it uses node, I needed to use a container environment. I cannot use the code in a browser environment because a browser cannot execute node.
That left me with the option of CodeSandbox. It turns out I was close by using the
Node HTTP server
template, but the person who helped me used theStatic HTML and JavaScript served via Node
template.That basically has a
server
folder with anindex.js
in it to initiate the environment, he just needed to upload mydist
andsrc
folders from my repo.I could probably use repl.it to run this if I didn't need Live Preview and the ability to make changes on the fly by uploading my
dist
after it had been bundled by webpack. But since the whole point of putting it on an online code editor is the ability to make changes, I needed to do it this way.I hope that makes sense. I hope I got it right!
Ok, yeah that makes more sense. @acchang