I have made a discord bot using JavaScript. When I use "node ." in the terminal to run the file and make it active, it doesn't work. What is the problem?
Have you set up node . as a script in your package.json file?
If you haven't yet, head over to your package.json file, within the scripts add "node .": "node index.js", so it looks something like this, remember to replace index.js with the name of your main file.
"scripts": {
"node .": "node index.js"
},
If you have done this and it still goes to error, please send the error that is displayed
Related
In the React file structure under components there is index.js file that runs the main character when running the project. Is there anyway to rename this file to any name I want? I am using PM2 server manager and there is no way for me to keep track which server is which when running multiple index.js files. So the only option I got is to rename this index.js to something specific to each project.
I have tried changing the package.json file's start script as below but nothing worked out only gave errors.
"scripts": {
"start": "test.js react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
Appreciate all your help!
You can't change the name of the file used by create-react-path.
You'll have to either eject to use custom webpack config by running
npm run eject
But it's a one-way operation (see documentation)
Or you can use Vite instead of create-react-app to bundle your project.
Vite is more configurable than create-react-app, you define in the index.html the name of your js file. So you can put any name you want.
Maybe even this example could help you:
https://vitejs.dev/guide/ssr.html#example-projects
I have an application that is a combination of a node middleware server and a next.js front end gui with react components. It was running ok, but then, when I tried to build it in production mode, I keep getting the following error:
UnhandledPromiseRejectionWarning: Error: Cannot find module 'C:\Users\mgardner\workspace\qa-tool-backoffice\.next\prerender-manifest.json'
Require stack:
- C:\Users\mgardner\workspace\qa-tool-backoffice\node_modules\next\dist\next-server\server\next-server.js
- C:\Users\mgardner\workspace\qa-tool-backoffice\node_modules\next\dist\server\next.js
- C:\Users\mgardner\workspace\qa-tool-backoffice\server.js
I'm a little confused as to how to get the next front end to run concurrently with the node/express server. Here's my package.json file:
{
"name": "ibo-ui",
"version": "0.1.0",
"private": true,
"scripts": {
"mockdb": "json-server --watch public/mockdb.json --port 3001",
"dev": "concurrently --kill-others \"json-server --watch public/mockdb.json --port 3001\" \"npm start\"",
"build": "next build",
"start": "node server.js && next start"
},
The reason this was happening was because my next build process was failing. It was failing because I had some old react functions in the public pages folder.
The issue was that my pages not generated at build time in Nextjs correctly due my path included not correctly try to check your page collecting data fully and pages generated correctly.
I am trying to figure out how to use the scripts inside package.json in my .core React project.
This is how it looks like:
"scripts": {
"start": "rimraf ./build && react-scripts start",
"build": "react-scripts build",
},
What if I want to add a custom script? For example, if I want to have a new script thats named "internal".
Whats the correct way to add this inside the script tag? And should I change something inside the .core Startup class? I mean how can the application know which Script to run if I don't define it somewhere?
Update: I have add the scripts from .core startup, but I am only getting interal server error (500) when trying this.
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseReactDevelopmentServer(npmScript: "start");
}
else if (env.IsStaging())
{
spa.UseReactDevelopmentServer(npmScript: "internal");
}
});
If you need more information. Please let me know.
Define your new script in the package.json:
"scripts": {
"start": "rimraf ./build && react-scripts start",
"build": "react-scripts build",
"internal": "(do something here)",
},
It looks like you're using ReactDevelopmentServerMiddlewareExtensions, so your spa.UseReactDevelopmentServer() takes a npmScript parameter that checks that package.json file and runs the command it finds there.
UPDATE:
Yes so your updated code looks like this is set up correctly on the .net end, you just need to write a corresponding script in package.json
I have recently started working on nextjs framework and I have created an index.js document inside pages folder. I wanted to implement social login authentication and found for some reasons I need to run next js in https mode.
Can anybody tell me how can I do that in dev machine.
Here is my error message
error message
and here is my package.json scripts
"scripts": {
"dev": "next -p 3001",
"build": "next build",
"start": "next start",
},
This article on freeCodeCamp looks promising :
https://www.freecodecamp.org/news/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec/
I'm learning ReactJS for a few weeks but I'm facing an issue that's impossible to solve by myself.
I use create-react-app command to start react project but it is totally impossible to use npm test after that. Even if I don't touch anything in the project, when I try to run npm test I only get "No tests found, exiting with code 0".... When I just create the project there is src/App.test.js but the command found nothing..... :(
Someone I sent the folder succeeded to run the tests.... is it possible that the problem comes from my computer/environment (Windows 10) ?
Thanks for help.
Have a good day
Add this line to your "package.json"
open package.json
find scripts in that "test" : "react scripts test" replace this with
"test": "react-scripts test --watchAll --testMatch **/src/**/*.test.js"
Now run npm test.
It works!
Got it!
I found this posts https://github.com/facebook/create-react-app/issues/7660
wich explain that npm test don't work with hidden directories (.xxx).
My projet is under C:\Users\kendr\.babun\cygwin\home\Kendrak\react\myprojet
The problem is the .babun !
I move my project in another dir and the test command now works fine!
If you are CRA(Create React App) user who is seeking proper answer, try this out in package.json.
`
{
"name": "Your App",
"jest": {
"testMatch": [
"<rootDir>/src/**/*.test.{js,jsx,ts,tsx}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}"
]
},
"version": "0.1.0",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --watchAll=false",
"eject": "react-scripts eject"
}
}
`
CRA manages jest in package.json. So if you use jest.configure.js in parent route you will get error about route something.
If you want another custom configuration give a changetestMatch.
As answered by #Kenkradstef, there can be issues with the path your project is in.
Had the same problem, with "[" "]" in my path. Full path was something like "C:\Users\xxx\[P]rojects\xxx\".
I moved the project to a different location and it worked.
Can't add a comment because I have no reputation, that's why I am posting this as an answer.