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)
Related
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
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
Just started training on TestCafe for new job.
For some reason I keep getting following error and I don't know why
ERROR The specified glob pattern does not match any file or the default test directories are empty.
Type "testcafe -h" for help.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! testcafe_training#1.0.0 test: `testcafe chrome ./test`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the testcafe_training#1.0.0 test 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/xx.xxx/.npm/_logs/2020-01-17T15_15_38_725Z-debug.log
xxx.xx#LPGxxx TestCafe_Training %
Here is the code and the package.json.
Code:
Fixture`Getting started with Testcafe`
.page`https://devexpress.github.io/testcafe/example/`;
Test('My first testcafe test', async t => {
//Enter you testcase here
await t.typetext('#developer-name', 'mary');
await t.click('#submit-button');
});
package.json:
{
"name": "testcafe_training",
"version": "1.0.0",
"description": "This is training",
"main": "TestCafeTrain.js",
"scripts": {
"test": "testcafe chrome ./test"
},
"keywords": [
"TestCafe",
"Automation",
"Testing"
],
"author": "",
"license": "ISC",
"dependencies": {
"testcafe": "^1.7.1"
}
}
Ok, I know what i did wrong.
The correct syntax for 'test' in package json. I should have run the folder name and removed './'
"test": "testcafe chrome TestSpec"
In the actual test there was a typo in the testcase. I wrote typetext incorrectly. This is what it should have looked like:
await t.typeText('#developer-name','mary')
Ran this code and it worked perfectly
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\""
I am using webpack to build my app so I am getting the following error on command prompt:
forkify#1.0.0 dev D:\Myprograms\java script\forkify
webpack --mode development
Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.
Hash: 750054014bbd689a84a8
Version: webpack 4.16.5
Time: 85ms
Built at: 2018-08-07 10:22:56
ERROR in Entry module not found: Error: Can't resolve './scr/js/index.js' in 'D:\Myprograms\java script\forkify'
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! forkify#1.0.0 dev: webpack --mode development
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the forkify#1.0.0 dev 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\Acer\AppData\Roaming\npm-cache_logs\2018-08-07T04_52_57_041Z-debug.log
My webpack.config.js is as follows:
const path = require('path');
module.exports = {
entry: './scr/js/index.js',
output: {
path: path.resolve(__dirname,'dist/js'),
filename: 'bundle.js'
}
};
My package.json file as follows:
{
"name": "forkify",
"version": "1.0.0",
"description": "forkify project",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production"
},
"author": "abhilash narayan",
"license": "ISC",
"devDependencies": {
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0"
}
}
Also check the screen shots
My file structure webpack.conifg.js:
It looks to me like a spelling mistake, entry: './scr/js/index.js
try to change it to ./src/js/index.js