Getting Error While starting lite-server in npm - node.js

i did a fresh "npm init". put entry point : "index.html"
then installed lite-server : npm install lite-server --save-dev
also updated the package.json and I Uninstalled, reinstalled tried everything but it's not working and
also tried npm cache clean --force but it's not working. can any one help with this error.
{
"name": "git-test",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "npm run lite",
"lite": "lite-server"
},
"author": "Sateesh",
"license": "ISC",
"dependencies": {
"lite-server": "^2.5.4"
}
}
But when I did "npm start" , getting this error
git-test#1.0.0 start D:\Coursera\git-test
> npm run lite
'npm' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! git-test#1.0.0 start: `npm run lite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the git-test#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! C:\Users\sai\AppData\Roaming\npm-cache\_logs\2020-06-05T10_20_11_723Z-debug.log

I was too facing the same issue after a system shutdown, hence this worked for me:
First uninstall the current local lite-server in node_modules
npm uninstall lite-server
Install lite-server globally and try running the same command
npm install -g lite-server
then hit:
npm start
This fixed the issue for me, thank you
Here's my Json file script if you want to have a look
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},

You don't seem to have node/npm installed and configured properly (PATH issues).
I would suggest you try to re-install Node.js using the official instructions for your platform (https://nodejs.org/en/download/) or by using a Node.js version manager like nvm (https://github.com/nvm-sh/nvm) or n (https://github.com/tj/n).
Using nvm or n, will allow you to dynamically switch Node.js version without having to re-install everything from scratch.

Just install the live-server globally,i think that should solve the issue.
sudo npm install --global lite-server
And in your package.json file you can change a little bit.
{
"name": "git-test",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "lite-server",
},
"author": "Sateesh",
"license": "ISC",
"dependencies": {
"lite-server": "^2.5.4"
}
}
After this run this on terminal
npm start
I think this should help :)

I had a similar issue,yarn start worked for

Related

how to fix "npm ERR! Missing script:"

I wrote the script "style", but for some reason does not want to execute it.
Using the npm run command, you can just execute the script "test": "echo "Error: no test specified" && exit 1"
My package.json is below, as well as the full error message when I run a command:
{
"name": "plants",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"style": "sass sass/style.scss sass/style.css",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
here I am trying to run a sktipt:
npm run style
npm ERR! Missing script: "style"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\GRAFIK548\AppData\Local\npm-cache\_logs\2022-12-28T06_18_17_306Z-debug-0.log
and here I look at what scripts can be run:
$ npm run
Lifecycle scripts included in plants#1.0.0:
test
echo "Error: no test specified" && exit 1
in general, I'm trying to connect sass via json
thank you very much for any answer!!
NPM err missing script fix
I used to get this error a lot on my old computer. The easiest fix I found that worked was to just
Try to use the absolute path of the file in your JSON.

Getting missing script: start error in npm

I get this error when I run npm start.
npm ERR! Missing script: "start"
npm ERR! Did you mean one of these?
npm ERR! npm star # Mark your favorite packages
npm ERR! npm stars # View packages marked as favorites
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER\AppData\Local\npm-cache\_logs\2022-04-28T13_04_19_260Z-debug.log
package.json has various sections, scripts is one of them, which allows you to write npm scripts which we can run using npm run <script-name>. The error you're getting is because your start script is missing in that section.
For a node app, your package.json file should look similar to this.
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.0",
"cors": "^2.8.5",
"express": "^4.17.3"
}
}
In the above code, focus on the scripts section. The following line is missing in your package.json file.
"scripts": {
"start": "node app.js",
},
Add this line and you're good to go.
Option_1: Control inside file "package.json":
"scripts": {
"start": "what command is here?",
},
Option_2: Control Terminal (folder) where you write command OR open the responding terminal for your project: right-click
on the project name -> "Open in integrated Terminal"
You have to put what command you need npm to run when you give npm start.
You have to write node index.js in scripts.start in your package.json file

Npm start problem while installing react, and how to fix it?

After installing node and global create-react-app using 'npm install -g create-react-app' I start creating my first app using 'npx(or npm i tried both) create-react-app appname' and it was successfully created until I start the 'npm start' in 'appname' directory which gave me the following errors.
E:\Sang\React\myapp>npm start
myapp#0.1.0 start E:\Sang\React\myapp
react-scripts-start
'react-scripts-start' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp#0.1.0 start: react-scripts-start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp#0.1.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! C:\Users\Sang Tonsing\AppData\Roaming\npm-cache_logs\2020-09-03T12_06_34_133Z-debug.log
This is my script code inside package.json
{
"name": "myfirstreact",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Kindly please help me solve my problem, I am planning to build my own website using react. Thank You so Much
"scripts":{
"start":"react-scripts-start",
"build":"react-scripts-build",
"test":"react-scripts-test",
"eject":"react-scripts-eject",
}
you have to go to your package.json file and look inside scripts,
you should see there start script. if you dont have just add it.
In your package.json file change the start script as:
"scripts": {
"start": "react-scripts start -o",
"build": "react-scripts build",
.
.
.
I think it's "start": "react-scripts-start" which is causing problem for you.
You may be missing the react-scripts module.
Run npm install react-scripts --save in your project and your package.json should be the way it was initially:
"scripts":{
"start":"react-scripts start",
"build":"react-scripts build",
"test":"react-scripts test",
"eject":"react-scripts eject",
}
nvm install 10.23.0
npm start
npm run build
Brother I think your npm version or nodejs version is outdated
You’ll need to have Nodejs >= 14.0.0 and npm >= 5.6 on your machine. Or use windows 8.1 , 10 . Not the windows 7
Simple delete the node_modules folder and run npm install in the appname directory. Let me know if it don't help.
delete node_modules
run npm install
after that run npm start
if above does't work
delete node_modules
delete package-lock.json
run npm install
and then npm start
if above solutions does not fixed your problem, try the following this worked for me:
if you want to start on another port or PORT command not found error then do the following steps:
open package.json file
inside script replace the start command with below "start": "set PORT=3006 && react-scripts start"

"." Is not a command or a bat When trying to serve project

So im currently building/working on a project on my win 10 machine, with nodeJS
But im running into a problem when running it. it says the following.
C:\Users\myuser\Documents\Gits\deon>npm start
> deon#1.0.0 start C:\Users\myuser\Documents\Gits\deon
> ./scripts/serve
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! deon#1.0.0 start: `./scripts/serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the deon#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! C:\Users\Melonendk\AppData\Roaming\npm-cache\_logs\2018-11-16T08_00_31_347Z-debug.log
I tried to check the system environment on windows as many others have posted on the internet but with no luck :(
How can I fix this problem?
Package.json
{
"name": "deon",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "./scripts/serve",
"start-prod": "./scripts/serve-bin",
"build": "./scripts/build",
"test": "echo \"Not implemented.\" && exit 1"
},
"author": "",
"contributors": [],
"license": "ISC",
"dependencies": {},
"devDependencies": {
"eslint": "^4.18.1"
}
}
My serve file.
#!/usr/bin/env bash
set -e
SRC=$PWD/src
HTML=$SRC/html
TEMPLATES=$(find "$SRC/templates" -iname '*.html')
web-build $HTML/begin.html \
$HTML/${1:-development}.html \
$HTML/head.html \
$HTML/begin-body.html \
$HTML/body.html \
$TEMPLATES \
$HTML/end.html \
serve -m -v --static $SRC --port ${2:-8080}
"start": ".\scripts\serve" change it to
"start": "node ./scripts/serve"
As Jonathan Jonathan mentioned in the comment you need to try this
"start": "node ./scripts/server,js"
or try something like this
"start": "cd scripts && node server.js"

`npm start` complains "missing script: start", without running node

I have the following files in my NPM package:
package.json:
{
"name": "npm-start",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
index.js
console.log('Hello world!');
When I try to run npm start, I get an error message:
> npm start
npm ERR! missing script: start
Okay, it's true: I don't have a "start" property in "scripts" object. But NPM's CLI Documentation claims this about npm start:
If no "start" property is specified on the "scripts" object, it will run node server.js.
Why is NPM failing me? Isn't it supposed to invoke node in this scenario? Am I missing something? (Of course, manually invoking node works fine).
In case it's relevant:
> npm -version
5.3.0
As soon as I finished typing the question, I realized my error.
When "start" property is absent, NPM will invoke node with server.js. But I don't have a server.js. NPM checks under the hood for this server.js file, and fails if it's not present. Ideally though, NPM should have reported that server.js wasn't found. The current way of handling things is confusing.
As soon as you have a server.js file, npm start works fine.
I had this issue as well. I re-installed my npm#4 and my node.js#6.4.0. Then created my project again using the commands
create-react-native-app AwesomeProject
sudo npm start (mac command)
It worked for me!

Resources