"npm run serve" giving error in windows cmd - windows

In windows, when I run the command "npm run serve" in command prompt for viewing my vue js project it is showing some errors
C:\Users\HOME\app>npm run serve
npm ERR! Missing script: "serve"
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\HOME\AppData\Local\npm-cache\_logs\2021-11-15T17_29_32_459Z-debug.log
The package.json of this is:
{
"name": "testapp",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"node": "^16.4.1",
"register-service-worker": "^1.7.1",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
},
"devDependencies": {
"#vue/cli-plugin-pwa": "~4.5.0",
"#vue/cli-plugin-router": "~4.5.0",
"#vue/cli-plugin-vuex": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

Related

NPM RUN WATCH doesn't finish it's job

Hi everyone I'm new in laravel, I'm using laravel 9, i tried to run (npm run watch) and it's about 30 mins nothing happened,
this's the message i get.
Hopefully I get some answers,
thank you in advance
i have tried npm run dev it doesn't work , so i replace it with npm run build .
this is what my package.json look like:
"private": true,
"scripts": {
"dev": "vite",
"watch": "npm-watch",
"build": "vite build"
},
"devDependencies": {
"#tailwindcss/forms": "^0.5.2",
"alpinejs": "^3.4.2",
"autoprefixer": "^10.4.2",
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.3",
"lodash": "^4.17.19",
"postcss": "^8.4.6",
"tailwindcss": "^3.1.0",
"vite": "^4.0.3"
},
"dependencies": {
"npm-watch": "^0.11.0"
},
"watch": {
"build": {
"patterns": [
"src"
],
"extensions": "js,jsx"
}
}
}
I added ( "watch": "npm-watch",)

Deploying Preact to Heroku

I've written a pretty simple app in Preact. No back end server, just front-end calling a web API and displaying the results.
I set it up on Heroku and it reports that it deployed successfully, but trying to access the app fails right out the gate:
2020-09-14T02:10:11.845503+00:00 heroku[web.1]: Starting process with command `npm start`
2020-09-14T02:10:14.403769+00:00 app[web.1]: npm ERR! missing script: start
How should I [define a start script to] make this work?
In development I run yarn dev like the Preact docs suggest. My guess is that's just a dev server though.
FWIW, Here's my package.json
{
"private": true,
"name": "clips-preact",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"build": "preact build",
"serve": "sirv build --port 8080 --cors --single",
"dev": "preact watch",
"lint": "eslint src"
},
"eslintConfig": {
"extends": "eslint-config-synacor"
},
"eslintIgnore": [
"build/*"
],
"devDependencies": {
"eslint": "^6.0.1",
"eslint-config-synacor": "^3.0.4",
"preact-cli": "^3.0.0",
"sirv-cli": "^1.0.3"
},
"dependencies": {
"axios": "^0.20.0",
"preact": "^10.1.0",
"preact-render-to-string": "^5.1.2",
"recoil": "^0.0.10"
}
}
I'm late, but to anyone who comes across this, you shouldn't be running a separate server at all.
Preact CLI builds to static output. Just point your webserver (nginx, apache) at the directory and let it handle serving the files.
Give this a try:
{
"private": true,
"name": "clips-preact",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"build": "preact build",
"serve": "sirv build --port 8080 --cors --single",
"dev": "preact watch",
"lint": "eslint src",
// Your file name ↓ make sure to remove this comment before you go.
"start": "node index.js"
}
You have to add "start" inside the "scripts" area, then as you running your script type "node your_file_name" this will make "npm start" command run "node your_file_name" command.

Decoupled Deployment of Web App using Heroku, gh-pages, and MySQL

My team and I created a MERN stack application (M for MySQL) that is planning on hosting our client on gh-pages and our server on heroku. So far we have been unable to deploy because we keep getting errors about our use of the npm package concurrently. Although we can access our heroku url and our gh-pages url, we are unable to connect the two
We have already tried adding a proxy to our package.json within our client folder and have added a .env.development Host name (heroku url)
Root Directory
- client
- package.json
- package-lock.json
- config
- config.json
- passport.json
- controllers
- models
- routes
- .env
- .env.development
- .gitignore
- package-lock.json
- package.json
- server.js
Server package.json
{
"name": "traveler",
"version": "1.0.0",
"homepage": "http://dchicchon.github.io/Traveler",
"description": "A social media platform for people who love traveling and those who want to explore.",
"main": "server.js",
"scripts": {
"start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
"start:prod": "node server.js",
"start:dev": "concurrently \"nodemon --ignore 'client/*'\" \"npm run client\"",
"client": "cd client && npm run start",
"seed": "node scripts/seedDB.js",
"install": "cd client && npm install",
"build": "cd client && npm run build",
"heroku-postbuild": "npm run build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.511.0",
"bcryptjs": "^2.4.3",
"concurrently": "^4.1.1",
"dotenv": "^8.0.0",
"express": "^4.17.1",
"express-session": "^1.16.2",
"gh-pages": "^2.0.1",
"multer": "^1.4.2",
"multer-s3": "^2.9.0",
"mysql2": "^1.6.5",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"sequelize": "^5.13.1"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/dchicchon/Traveler.git"
},
"bugs": {
"url": "https://github.com/dchicchon/Traveler/issues"
}
}
Client package.json
{
"name": "traveler",
"version": "0.1.0",
"proxy": "https://travelersite.herokuapp.com/",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"google-map-react": "^1.1.4",
"lodash": "^4.17.15",
"materialize-css": "^1.0.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-router-dom": "^5.0.1",
"react-scripts": "3.1.0",
"styled-components": "^4.3.2"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"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"
]
},
"devDependencies": {
"gh-pages": "^2.1.1"
}
}
After entering the command heroku create and git push heroku master we would expect that our server will be pushed to heroku and our client will be deployed to gh-pages.
Does removing heroku-postbuild script from your backend package.json work?

Getting "npm start" error when deploy Node JS app to Heroku server

I'm getting this error when i deploy my NodeJS app to Heroku server.
2019-08-27T05:54:03.597197+00:00 heroku[web.1]: State changed from starting to crashed
2019-08-27T05:54:03.569746+00:00 heroku[web.1]: Process exited with status 1
2019-08-27T05:59:55.107447+00:00 heroku[web.1]: State changed from crashed to starting
2019-08-27T05:59:58.079934+00:00 heroku[web.1]: Starting process with command `npm start`
2019-08-27T06:00:00.687008+00:00 heroku[web.1]: State changed from starting to crashed
2019-08-27T06:00:00.660988+00:00 heroku[web.1]: Process exited with status 1
2019-08-27T06:00:00.452248+00:00 app[web.1]: > realtime-chat#1.0.0 start /app
2019-08-27T06:00:00.452250+00:00 app[web.1]: > node index.js
2019-08-27T06:00:00.452252+00:00 app[web.1]:
2019-08-27T06:00:00.574510+00:00 app[web.1]: /app/index.js:1
2019-08-27T06:00:00.574514+00:00 app[web.1]: import express from "express";
2019-08-27T06:00:00.574517+00:00 app[web.1]: ^^^^^^^
2019-08-27T06:00:00.574519+00:00 app[web.1]:
2019-08-27T06:00:00.581327+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-08-27T06:00:00.581759+00:00 app[web.1]: npm ERR! errno 1
2019-08-27T06:00:00.582977+00:00 app[web.1]: npm ERR! realtime-chat#1.0.0 start: `node index.js`
2019-08-27T06:00:00.583139+00:00 app[web.1]: npm ERR! Exit status 1
2019-08-27T06:00:00.583436+00:00 app[web.1]: npm ERR!
2019-08-27T06:00:00.583640+00:00 app[web.1]: npm ERR! Failed at the realtime-chat#1.0.0 start script.
2019-08-27T06:00:00.583830+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-08-27T06:00:00.593702+00:00 app[web.1]:
My config: package.json file.
{
"name": "realtime-chat",
"version": "1.0.0",
"description": "sjc-realtimechat",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "babel-node index.js",
"postinstall": "bower cache clean && bower install"
},
"keywords": [
"sjc"
],
"author": "sjc-bui",
"license": "ISC",
"dependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"bcrypt": "^3.0.6",
"bluebird": "^3.5.5",
"body-parser": "^1.19.0",
"bower": "^1.8.8",
"connect-mongo": "^3.0.0",
"cookie-parser": "^1.4.4",
"dotenv": "^8.0.0",
"ejs": "^2.6.2",
"emojione": "^4.5.0",
"express": "^4.17.1",
"express-flash": "0.0.2",
"express-session": "^1.16.2",
"express-validator": "^6.1.1",
"fs-extra": "^7.0.1",
"google-translate": "^2.2.0",
"http": "0.0.0",
"https": "^1.0.0",
"lodash": "^4.17.11",
"moment": "^2.24.0",
"mongoose": "^5.6.4",
"multer": "^1.4.1",
"nodemailer": "^4.4.2",
"passport": "^0.4.0",
"passport-google-oauth": "^2.0.0",
"passport-local": "^1.0.0",
"passport.socketio": "^3.7.0",
"request": "^2.88.0",
"socket.io": "^2.2.0",
"uuid": "^3.3.2"
},
"devDependencies": {}
}
My config: Procfile file
web: npm start
i'm trying to run babel-node index.js on server. but got this error
npm ERR! realtime-chat#1.0.0 start: node index.js
I was searching to fix it but still got this error. Please help.
Update
Dependences already installed but still got "npm start" error.
Update all required dependencies in your package.json.
package.json should be something similar to this :
{
"name": "sample name",
"version": "version details goes here",
"description": "description goes here",
"main": "index.js",
"scripts": {
"start": "babel-node index.js",
"dev": "nodemon --exec babel-node index.js",
"test": "mocha --require babel-core/register test/*.js",
"compile": "babel src --out-dir .compiled --source-maps --watch",
"postinstall": "bower cache clean && bower install"
},
"dependencies": {
"express": "^4.9.8",
"other dependencies"
},
"engines": {
"node": "put node version details here"
}
}
update your bablerc file as below:
babelrc content
{
"presets": ["#babel/preset-env"]
}
Babel node is missing from your dependencies list.
also, see this below guide for more details:
https://devcenter.heroku.com/articles/deploying-nodejs
you cannot use
import express from "express"
this is ES-15 modules and Node.js does not support this. React supports this. node.js runtime has support for common.js modules which should be like this:
const express=require("express")

What is executed when only running yarn?

When running a script defined within the package.json the usual way to go with yarn is yarn run myscriptname. But what exactly is executed when only running yarn without run myscriptname? It still compiles everything, but I wonder what exactly and where it gets its information from on what to run when called without parameter. The example I am working with is a project in GitHub and the package.json looks like this:
{
"private": true,
"name": "parent",
"version": "0.0.0",
"engines": {
"yarn": "1.0.x || >=1.2.1",
"node": ">=7.9.0"
},
"devDependencies": {
"#types/chai": "^4.0.1",
"#types/chai-as-promised": "0.0.31",
"#types/chai-string": "^1.4.0",
"#types/jsdom": "^11.0.4",
"#types/mocha": "^2.2.41",
"#types/sinon": "^2.3.5",
"#types/temp": "^0.8.29",
"#types/webdriverio": "^4.7.0",
"chai": "^4.1.0",
"chai-string": "^1.4.0",
"concurrently": "^3.5.0",
"electron-mocha": "^3.5.0",
"istanbul": "^0.4.5",
"istanbul-instrumenter-loader": "^3.0.0",
"jsdom": "^11.5.1",
"lerna": "^2.2.0",
"mocha": "^3.4.2",
"nyc": "^11.0.3",
"remap-istanbul": "^0.9.5",
"rimraf": "^2.6.1",
"selenium-standalone": "^6.2.0",
"sinon": "^3.3.0",
"temp": "^0.8.3",
"ts-node": "^3.2.0",
"tslint": "^5.7.0",
"typedoc": "^0.8",
"typescript": "^2.7.2",
"uuid": "^3.1.0",
"wdio-mocha-framework": "^0.5.9",
"wdio-phantomjs-service": "^0.2.2",
"wdio-selenium-standalone-service": "0.0.8",
"wdio-spec-reporter": "^0.1.0",
"webdriverio": "^4.6.2"
},
"scripts": {
"prepare": "yarn rebuild:clean && yarn build:clean",
"build": "run build",
"build:clean": "run prepare",
"docs": "run docs \"#theia/!(example-)*\"",
"test": "yarn test:theia && yarn test:electron && yarn test:browser",
"test:theia": "run test \"#theia/!(example-)*\" --parallel",
"test:browser": "yarn rebuild:browser && run test \"#theia/example-browser\"",
"test:electron": "yarn rebuild:electron && run test \"#theia/example-electron\"",
"rebuild:clean": "rimraf .browser_modules",
"rebuild:browser": "theia rebuild:browser",
"rebuild:electron": "theia rebuild:electron",
"rebuild:electron:debug": "DEBUG=electron-rebuild && yarn rebuild:electron",
"watch": "lerna run watch --scope \"#theia/!(example-)*\" --parallel",
"publish": "yarn && yarn test && yarn publish:latest",
"publish:latest": "lerna publish --registry=https://registry.npmjs.org/ --skip-git",
"publish:next": "lerna publish --registry=https://registry.npmjs.org/ --exact --canary=next --npm-tag=next --force-publish --skip-git --yes"
},
"workspaces": [
"dev-packages/*",
"packages/*",
"examples/*"
]
}
According to: https://yarnpkg.com/lang/en/docs/cli/#toc-default-command
Running yarn with no command will run yarn install, passing through any provided flags.
yarn === npm install
It just install node packages from package.json and their dependencies.
(You shouldn't use Yarn nowadays. NPM is fastest)

Resources