"concurrently command not found" but installed gloabally - javascript

I'm using macOs and even though concurrently is installed globally through npm, when setting it as a start script in package.json and typing npm start the following error occurs.
concurrently - kill-others "npm run server" "npm run client"
sh: concurrently - kill-others: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! thesis_fullstack#1.0.0 start: `concurrently - kill-others "npm run server" "npm run client"`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the thesis_fullstack#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mantzaris/.npm/_logs/2020-04-25T22_40_12_897Z-debug.log
My package.json file :
{
"name": "thesis_fullstack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"client": "cd client && npm start",
"server": "cd server && npm start",
"start": "concurrently - kill-others \"npm run server\" \"npm run client\""
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"concurrently": "3.5.1"
}
}

You need to install the dependency locally in order to use it in any of your start scripts. run
npm install --save concurrently
to install it locally in your project

Your error is not with the package itself, you can either have it globally or save it locally (not --save-dev).
You can find the solution for your problem looking at the error log
concurrently - kill-others "npm run server" "npm run client"
sh: concurrently - kill-others: command not found
The command should be either --kill-others or -k for short, here is the official documentation: https://github.com/kimmobrunfeldt/concurrently
Try this as your package.json
{
"name": "thesis_fullstack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"client": "cd client && npm start",
"server": "cd server && npm start",
"start": "concurrently --kill-others \"npm run server\" \"npm run client\""
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"concurrently": "3.5.1"
}
}
Cheers :)

I seriously don't know what I did to fix it. First of all i fixed the command flag "typo" to concurrently --kill-others your_commands_here. Then i uninstalled node manually and reinstalled it through Homebrew (since I'm using MacOs). After that node and npm wouldn't work at all. Fixed it with: https://stackoverflow.com/a/54583099/13212764. I think by that point running npm start worked.

For
Globally -
npm install -g concurrently
Locally -
npm install concurrently

Related

fail parcel build command exit code errno 3221225501 /code ELIFECYCLE

I,m trying to run 'npm run build' but always get error, 'npm run start' command is run correcly,but build command not run.:(
{
"name": "films",
"version": "1.0.0",
"description": "contain about films",
"default": "index.html",
"scripts": {
"start": "parcel index.html",
"build": "parcel build index.html --dist-dir ./dist "
},
"author": "chathura priyashan",
"license": "ISC",
"devDependencies": {
"parcel": "^2.3.2"
},
"dependencies": {
"node-sass": "^7.0.1"
}
}
err--------------------------------------------------
npm ERR! code ELIFECYCLE
npm ERR! errno 3221225501
npm ERR! films#1.0.0 build: `parcel build index.html `
npm ERR! Exit status 3221225501
npm ERR!
npm ERR! Failed at the films#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\chathura\AppData\Roaming\npm-cache\_logs\2022-03-28T14_56_48_033Z-debug.log
PS G:\java script sites\Asynchronus\films> npm run build

Why does npm not start? [duplicate]

This question already has answers here:
How to solve npm error "npm ERR! code ELIFECYCLE"
(49 answers)
Closed 1 year ago.
My server works well when I run node app.js. However, I am trying to use nodemon to run my server and it doesn't start.
npm start shows the following error:
npm ERR! code ELIFECYCLE
npm ERR! errno 9009
npm ERR! lab11#1.0.0 start: nodemon app.js
npm ERR! Exit status 9009
npm ERR!
npm ERR! Failed at the lab11#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
My package.json:
{
"name": "lab11",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"nodemon": "^2.0.7"
},
"dependencies": {
"express": "^4.17.1"
}
}
My app.js
const express = require('express');
const app = express();
app.use((request, response, next) => {
console.log('Middleware!');
next();
});
app.use((request, response, next) => {
console.log('Otro middleware!');
response.send('¡Hola mundo!');
});
app.listen(3000);
I already tried to:
Delete node_modules and run npm install
Delete package-lock.json, run npm cache clean --force and run npm install
Delete all files and repeat the installation process
Add npm to path
Other solutions to this question
According to this answer there are still a few options that you might want to try:
Remove the lock file.rm .\package-lock.json
Correct permissions (on *nix)chmod -R a+rwx ./node_modules
Force chache cleaningnpm cache clean --force
Double-check you're not already running your app in background, locking the port (eg. 8080)

npm install lite-server --save-dev installation error

I am trying to use node for the first time,installed node.js below is the information
node -v
v14.4.0
npm -v
6.14.5
Completed the setup by creating a package.json file, then tried to install lite-server using the command
npm install lite-server --save-dev produced the folllowing error:
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ojhaa\AppData\Roaming\npm-cache\_logs\2020-06-06T06_54_54_480Z-debug.log
Followed by
npm cache clean --force
Here is the package.json file
{
"name": "git-test",
"version": "1.0.0",
"description": "\"This is a test directory to learn git and node\"",
"main": "index.html",
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},
"repository": {
"type": "git",
"url": "git+https://github.com/apoorva0212/git-test.git"
},
"author": "\"Apoorva Ojha\"",
"license": "ISC",
"bugs": {
"url": "https://github.com/apoorva0212/git-test/issues"
},
"homepage": "https://github.com/apoorva0212/git-test#readme"
}
But still I get the same error. Can anyone help me with this?
Thank you, in advance.
you are missing the dependency on lite-server
try to install lite-server dependency
npm install lite-server --save-dev
then invoke npm run lite

How to run ts script with package.json?

I try to run typescript files with just a package.json file. So a minimum setup for running typescript files.
I just have a singel file: index.ts:
console.clear();
console.log("nic to see you!!");
and package.json file:
{
"name": "Todo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC"
}
But if I try to do :
npm start, I will get this error:
Error: Cannot find module 'D:\Mijn Documents\UDEMY\TypeScript\Todo\index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Todo#1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Todo#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User.USER-PC\AppData\Roaming\npm-cache\_logs\2019-12-24T11_22_12_024Z-debug.log
PS D:\Mijn Documents\UDEMY\TypeScript\Todo>
So my question is: what I have to change that it will compile?
Thank you
oke, I have it now like this:
packagege.json:
{
"name": "Todo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build":"tsc -p ./src",
"start": "npm run build -- -w"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"ts-node": "^8.5.4",
"typescript": "^3.7.4"
}
}
And I installed typescript
and I do: npm start. I still get this error:
npm run build -- -w
> Todo#1.0.0 build D:\Mijn Documents\UDEMY\TypeScript\Todo
> tsc -p ./src "-w"
error TS5057: Cannot find a tsconfig.json file at the specified directory: './src'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Todo#1.0.0 build: `tsc -p ./src "-w"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Todo#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User.USER-PC\AppData\Roaming\npm-cache\_logs\2019-12-24T11_33_38_340Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Todo#1.0.0 start: `npm run build -- -w`
npm ERR! Exit status 1
oke, I have it now like this:
{
"name": "Todo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc main.ts dist/",
"start": "npm run build -- -w"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"ts-node": "^8.5.4",
"typescript": "^3.7.4"
}
}
and if I do this: npm run. I see this output:
> Todo#1.0.0 build D:\Mijn Documents\UDEMY\TypeScript\Todo
> tsc main.ts dist/ "-w"
[1:46:58 PM] Starting compilation in watch mode...
error TS6053: File 'dist/.ts' not found.
[1:46:59 PM] Found 1 error. Watching for file changes.
oke, I see now this:
> Todo#1.0.0 build D:\Mijn Documents\UDEMY\TypeScript\Todo
> tsc -p ./ "-w"
[2:00:31 PM] Starting compilation in watch mode...
[2:00:34 PM] Found 0 errors. Watching for file changes.
But where I can see the results then? Will be nice to go to some port, like: localhost:4200 in the browser, but how to do that?
Try typing in the terminal as follows:
ts-node ./src/index.ts
Or, try the following modifications to the "start" script:
"start": "ts-node ./src/index.ts"
Thank you all!!
the trick was this in the package.json:
"start": "tsc-watch --onsuccess \"node dist/index.js\""

Npm scripts always gives an error as "is not recognized as an internal or external command"

I have a lerna repo. There is devDependency to concurrently package from my root package.json. When I type "lerna bootstrap" to command line, it works properly and install all root and subPackages` dependencies to root node_modules folder. But when i type "npm start" it says: 'concurrently' is not recognized as an internal or external command. When i check node_modules/concurrently folder it exists without problem.
My start script is concurrently --kill-others "npm run start-client" "npm run start-server".
This situation same with webpack-dev-server. How can i fix this problem except reinstalling everything.
package.json:
{
"name": "x-workspace",
"private": true,
"workspaces": [
"packages/*"
],
"devDependencies": {
"concurrently": "3.5.0",
"lerna": "^2.11.0"
},
"scripts": {
"start": "concurrently --kill-others \"npm run start-client\" \"npm run start-server\"",
"build": "webpack --hot",
"start-client": "npm --prefix ./packages/client-app start",
"start-server": "cd ./packages/server-app && dotnet run",
"clean": "rimraf node_modules package-lock.json ./packages/client-app/package-lock.json"
}
}
I found problem. There is no .bin folder in root node_modules folder. This is result of updating yarn to 1.8.0. When i return back to yarn 1.6.0, it works perfectly.
Thanks to David R. and other users.
I believe you don't have the concurrently package installed globally, To confirm try executing the below command and check if it returns anything,
npm list -g concurrently
If you've received an --(empty) response, then you'll have to install it globally.
npm install -g concurrently
Hope this helps!.

Categories