Tell us what’s happening:
I imported the repo into replit but when I tried running it, it keep complaining about use: command not found and wont log Hello World.
Your project link(s)
Project Link: boilerplate-express - Replit
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Challenge Information:
Basic Node and Express - Meet the Node console
run button is not configure :
go open the tree dots in files,click on show hidden files,scrol down to .replite
in side of thet file :
modules = ["nodejs-18:v3-20230608-f4cd419"]
hidden = [".config", "package-lock.json"]
run = "Use run command "
[nix]
channel = "stable-23_05"
[unitTest]
language = "nodejs"
[deployment]
run = ["sh", "-c", "Use run command "]
deploymentTarget = "cloudrun"
ignorePorts = false
change this :
run = "Use run command "
in to :
run = "node myApp.js "
then in here :
run = ["sh", "-c", "Use run command "]
do the same :
run = ["sh", "-c", "node myApp.js "]
Hope his helps…
it still doesnt work sadly
This topic might help you out.
Happy coding.
I’ve tried everything possible but it keeps showing not found whenever I try the /json in my web view. I even added a cors but it still isn’t working
import express from 'express';
import cors from 'cors';
const app = express();
app.use(cors());
app.get('/json', (req, res) => {
return res.status(200).json({"message": "Hello json"});
});
Your project link(s)
solution: boilerplate-npm - Replit
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/53…
Alright, you just need one file index.js for your express. Include your code and
app.listen(3000, () => { // Make your API live
console.log('Express server initialized');
});
And the package.json with the express package. Replit provides you a template with the prepared setup. What you need to do is to add the cors and change the routes.
Hope this helps.
here is the bilerplete-template link
boilerplate-expres-Meet the Node console
the button is configure
with npm run start …
fork it if you like…
nibble
November 8, 2023, 9:10am
6
Hi @zaklina
I don’t think node myApp.Js
is correct. Shouldn’t it be node myApp.js
?
it is expleind above , you could use
npm run start
to start the server
Your app should be running from server.js
, not myApp.js
. Often if you don’t configure the Run command when you initially import the repl, it will try to run from index.js
(which in this case does not exist).
In future, ensuring that you configure the Run command when you fork the repl (as per the challenge instructions) should avoid any problems, but you can fix it by making the following edits to the .replit
file:
Change entrypoint
to server.js
.
Ensure that the run
command is npm start
.
system
Closed
May 8, 2024, 10:17pm
9
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.