package.json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "cd profile-app-server && nodemon server.js",
"client": "cd client/profile-front-end && npm start",
"start": "concurrently \"npm run dev\" \"npm run client\" "
},
npm ERR! enoent ENOENT: no such file or directory, open '/Users/SebastianRusso/Desktop/profile-app/package.json'
when i run them separately, they both work fine. the server is running on 3001, so not to interfere with react.
the app is called, 'profile-app' which holds a 'client folder' which holds, 'profile-front-end'
the app, 'profile-app' also holds 'profile-app-server'
i'm wondering if i have the paths mixed up somehow. I've played around and tried different things, but kind of at a road block now
so basically to make both run, only the client can be in another folder.
i put the server in a separate folder as well, but that was incorrect, and that's why npm start could not find the folder.
in the end i removed the server folder, and changed the code to this and it works (runs both client side and server side)
"dev": "nodemon server.js",
"client": "cd client/avybe-challenge-profile && npm start",
"start": "concurrently \"npm run dev\" \"npm run client\" "
My guess is you need to figure out the path to get from your server package.json to your client package.json file. The client path for your script may need to be slightly altered.
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "cd profile-app-server && nodemon server.js",
"client": "cd ../client/profile-front-end && npm start",
"start": "concurrently \"npm run dev\" \"npm run client\" "
},
Not sure if that's the correct path, but it is probably somewhere along those lines.
Related
I'm trying to have my npm start script run json-server in the background in parallel to then running react-scripts to start UI. How would I go about doing this? I've tried various things with single & and prestart, etc but everything results in json-server starting to watch my db file but then react-scripts doesn't run.
The main 2 which I thought should do the trick are below, but neither work.
"scripts": {
"prestart" : "json-server --watch ../sample-db.json --port 3010 --delay 800&",
"start": "set HTTPS=true&&react-scripts start",
and
"scripts": {
"start": "json-server --watch ../sample-db.json --port 3010 --delay 800&set HTTPS=true&&react-scripts start",
Not quite a duplicate, but as indicated by #Max this has a few options:
How can I run multiple npm scripts in parallel?
So here's one way:
"scripts": {
"start": "set HTTPS=true&&react-scripts start",
"mockserver": "json-server --watch ../sample-db.json --port 3010 --delay 800",
"startdev": "concurrently --kill-others \"npm start\" \"npm run mockserver\"",
}
And I see that on windows I need to use "start" which was why single ampersand wasn't working.
I'm deploying Nodejs application to Droplet of Digitalocean.When I start it normal(npm start), it work perfectly.But when i start with pm2 , i get this error in pm2 logs.
Error during Data Source initialization error: password authentication failed for user "root"
this is script in my package.json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "tsc -w",
"server": "nodemon dist/index.js",
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js -d ./dist/data-source.js",
"build": "rm -rf dist && tsc",
"start": "NODE_ENV=production node dist/index.js"
},
I dont use root as owner rule when create database on Droplet, but i dont know why it happen, how can i fix it?
I have client and server in a separate folder. I think there is an error in client Script. can anyone help me out with the solution. I want to run both client and server simultaneously. Thanks
my folder structure
----client
----server
package.json inside server folder
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"server": "nodemon server.js",
**"client": "npm start --prefix client",**
"dev": "concurrently \"npm run server\" \"npm run client\""
}
As you have separate package.json files for the server and client, please try this solution
package.json inside the server folder
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"server": "nodemon server.js",
**"client": "npm start --prefix client",**
"dev": "concurrently \"npm run server\" \"cd ./../client && npm run client\""
}
Also you can try this one
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"server": "nodemon server.js",
**"client": "npm start --prefix client",**
"dev": "npm run server & (cd ./../client && npm run client)"
}
My app did work but I want to re-organise it so it is easier to manage. I want to move the server files from the root to their own directory.
Currently I use concurrently to load my server and client so they can run simultaneously.
When I run npm run dev I want concurrently to load the server and the client. When run the server loads, the client fails and a new folder called client gets generated in within the server directory.
My new folder structure
client
client/package.json
server
server/package.json
The previous (working) folder structure
server files in root
package.json {for server}
/client {all client files including /client/package.json}
I am using concurrently and am trying to get it now to work. I think I need to do is change to the correct syntax in my server/package.json file but the changes have not worked.
concurrently code in my server package.json file
"dev": "concurrently \"npm run server\" \"npm run client\"",
I get the error
] /bin/sh: ..npm: command not found
[1] ..npm run client exited with code 127
I have tried changing the line different ways but still cannot get the client to load
"dev": "concurrently \"npm run server\" \"cd ../client && /npm run client\"",
"dev": "concurrently \"npm run server\" \"cd ../client && /npm run client\"",
"dev": "concurrently \"npm run server\" \"npm run ./client\"",
"dev": "concurrently \"npm run server\" \"npm run ../client\"",
"dev": "concurrently \"npm run server\" \"npm run //client\"",
I think it may be a simple syntax change however the fact a new directory is getting created makes me a bit more concearned. Any solutions or thoughts would be appreciated.
The correct code in the package.json for the server is below
"scripts": {
"start": "node server.js",
"server": "nodemon server.js",
**"client": "npm start --prefix ../client/",**
"clientinstall": "npm install --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client "
},
I had to put the path to the new client directory after the command. Seems obvious now I know but I was focussing on the other line.
Combine two commands in the second argument that target the client location and npm command
"dev": "concurrently \"npm run server\" \"cd ../client && npm run client\"",
I realize that this is most likely a duplicate question. I'm new to nodemon and I'm trying to establish a server for a Vue JS project with nodemon. I'm trying to run eslint with nodemon and can't figure out why I keep getting the error message. If I remove npm after --exec it will tell me ''run' is not recognized, and if I remove that I will get ''lint' is not recognized and so on.
My package.json file:
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon src/app.js --exec 'npm run lint && node'",
"lint": "eslint **/*.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"eslint": "^4.16.0",
"nodemon": "^1.14.12"
}
}
I have also tried this code in my start scripts:
"scripts" : {
"start": "./node_modules/nodemon/bin/nodemon.js src/app.js --exec 'npm run lint && node'",
"lint": "./nodemodules/.bin/eslint **/*.js"
}
Where is tells me that "." is not recognized as an internal external command.
I've installed nodemon into my server folder and in the project directory as well as globally. I have done the same with eslint as well.
i had the same problem today. did some google stuff and found that this is not working anymore. so i tried this
"scripts": {
"prestart": "npm run lint ",
"start": "nodemon src/app.js ",
"lint": "./node_modules/.bin/eslint src/*.js"
},
when you npm start node will run the pre-start script before the start script.Once a file being updated this pre-start wont run by the nodemon.So for that we have to call the nodemon events.So create a nodemon.json on root folder and paste following.
{
"events": {
"restart": "npm run lint"
}
}
you can read more nodemon config options from here nodemon config .There are more nodemon events.you can read them from here event restart
PS:im very new to this. :)
EDIT1:
You can use as follows. this dont need a nodemon config;
"scripts": {
"start": "node src/app.js",
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "nodemon src/app.js --exec \"npm run lint --fix && node\"",
"lint": "eslint --fix **/*.js "
}
for run use npm run dev it will run es lint + nodemon. this is for windows cmd command.if you are using bash terminal, remove \ in "dev" ;
"dev": "nodemon src/app.js --exec "npm run lint --fix && node""
I had the same problem.
For some reason you can't use simple quotes in npm scripts.
Use escaped double quotes instead. This should work:
"start": "nodemon src/app.js --exec \"npm run lint && node\""
install it globally for making it available on path.
npm i -g nodemon
or if using yarn
yarn global add nodemon
and if you tried this approach and it didn't work.
you should try running it locally..
you have to create a script in your package.json like this
"script": {
"server" : "nodemon scriptFile.js" //name of the file you want to run
}
then use,
npm run server
but before it,
install nodemon locally.
check it, if it is available on package.json