What is executed when only running yarn? - yarnpkg

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)

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",)

Webpack not found when deploying using heroku

I'm trying to deploy an app on heroku, but I'm getting an error when it tried to build the app with the webpack command. I have tried a number of fixes but can't seem to get it to work. I tried running the webpack.js file from node_modules like this node node_modules/webpack/bin/webpack.js but that didn't work either. Any ideas would be greatly appreciated! Here is my package.json file:
{
"name": "waste-not-client",
"version": "1.0.0",
"description": "",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "concurrently npm:watch:*",
"build": "webpack --mode production",
"watch:compile": "webpack --mode development --watch",
"watch:serve": "nodemon server/server.js",
"heroku-postbuild": "npm install && npm run build && node server/server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Blue-ocean-HR/blueocean-client.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Blue-ocean-HR/blueocean-client/issues"
},
"homepage": "/",
"dependencies": {
"#auth0/auth0-react": "^1.12.0",
"axios": "^1.1.3",
"compression": "^1.7.4",
"concurrently": "^7.6.0",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"framer-motion": "^7.6.7",
"nodemon": "^2.0.20",
"path": "^0.12.7",
"react": "^18.2.0",
"react-autocomplete-input": "^1.0.19",
"react-dom": "^18.2.0",
"react-router-dom": "^6.4.3",
"webpack-bundle-analyzer": "^4.7.0"
},
"devDependencies": {
"#babel/core": "^7.12.3",
"#babel/plugin-syntax-jsx": "^7.18.6",
"#babel/preset-env": "^7.12.1",
"#babel/preset-react": "^7.12.5",
"autoprefixer": "^10.4.13",
"babel-jest": "^29.1.2",
"babel-loader": "^8.2.1",
"compression-webpack-plugin": "^10.0.0",
"css-loader": "^6.7.1",
"dotenv-webpack": "^8.0.1",
"postcss": "^8.4.19",
"postcss-loader": "^7.0.1",
"postcss-preset-env": "^7.8.3",
"style-loader": "^3.3.1",
"tailwindcss": "^3.2.4",
"webpack": "^5.75.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1"
},
"engines": {
"node": "v16.16.0"
}
}
The error when I try to deploy on heroku:
sh: 1: webpack: not found
Your start script looks like it's designed for development work with live reloading. That's not what you want on Heroku.
You could rewrite your package.json scripts, but the easiest solution is probably to add a Procfile that Heroku will use in preference to your start script, e.g.
web: node server/server.js
You'll also want to remove your heroku-postbuild script entirely. It just repeats two things that Heroku does automatically (installing dependencies and running your build), and it also includes the runtime command that we now have in our Procfile.

Facing problem while trying to run npm start after installing parallelshell#3.0.2 and onchange#7.1.0

This is my package.json file -->
{
"name": "aboutus",
"version": "1.0.0",
"description": "This is a website for Ristorante Con Fusion",
"main": "index.html",
"scripts": {
"start": "npm run watch:all",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server",
"scss": "node-sass -o css/ css/",
"watch:scss": "onchange \"css/*.scss\" --npm run scss",
"watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\" "
},
"author": "",
"license": "ISC",
"devDependencies": {
"lite-server": "^2.3.0",
"node-sass": "^5.0.0",
"onchange": "^7.1.0",
"parallelshell": "^3.0.2"
},
"dependencies": {
"bootstrap": "^4.0.0",
"bootstrap-social": "^5.1.1",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"popper.js": "^1.16.1"
}
}
This is the error I'm getting ,please help!
It is the problem with the version of parallelshell write this:
npm install --save-dev onchange#3.3.0 parallelshell#3.0.1
It will solve your problem.

Issue in path of deployed MERN app on heroku

getting Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
package.json
"name": "google-contacts-backend",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"dev": "nodemon ./bin/www",
"test": "nyc _mocha --timeout 10000 --exit --report lcovonly -- -R spec",
"lint": "eslint --fix --config .eslintrc.json \"**/*.js\"",
"heroku-postbuild": "cd client && npm install --only=dev && npm install && npm run build"
},
"dependencies": {
"axios": "^0.19.2",
"bcrypt": "^3.0.6",
"codacy-coverage": "^3.4.0",
"cookie-parser": "~1.4.3",
"cors": "^2.8.5",
"debug": "~2.6.9",
"dotenv": "^8.2.0",
"express": "~4.16.0",
"express-jwt": "^5.3.1",
"express-validator": "^6.2.0",
"googleapis": "^58.0.0",
"jsonwebtoken": "^8.5.1",
"mocha-lcov-reporter": "^1.3.0",
"moment": "^2.24.0",
"morgan": "~1.9.0",
"nodemailer": "^6.3.1"
},
"devDependencies": {
"chai": "^4.2.0",
"chai-http": "^4.3.0",
"eslint": "^6.5.1",
"mocha": "^6.2.2",
"nodemon": "^1.19.4",
"nyc": "^14.1.1"
}
}```
server.js
```app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "client", "build", "index.html"));
});
when I tried to check client folder directly in heroku bach, it was empty.

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?

Resources