Eslint and start webpack - npm

I would like to run eslint before webpack start.
I installed parallel and npm-run-all packages but didn't help.
When I type: npm run dev I get:
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! myproject-ui#1.0.0
eslint: eslint src/ npm ERR! Exit status 1 npm ERR! npm ERR! Failed
at the myproject-ui#1.0.0 eslint script. npm ERR! This is probably not
a problem with npm. There is likely additional logging output above.
My package.json:
"scripts": {
"start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"test": "mocha --compilers js:babel-core/register ./tests/**/*.js",
"test:watch": "npm run test -- --watch",
"code:coverage": "nyc npm run test",
"eslint": "eslint src/",
"dev": "npm-run-all --parallel start eslint"
},
Any idea how to run eslint and webpack parallel?;)
Greetings

It's not elegant solution but works fine
"lint": "eslint src || exit 0",
"dev": "npm-run-all --parallel lint start"
Because link returns exit 1 err so it makes them work parallel even though ;).

Related

npm start is failed, but node_modules/.bin/react-app-rewired start is successful

package.json:
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test"
}
I run 'npm start', then:
'react-app-rewired' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! map#0.1.0 start: `react-app-rewired start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the map#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
But I run 'node_modules/.bin/react-app-rewired start' in PowerShell, it's successful.

How to get npm to install a single package?

I have downloaded an npm project, and npm install fails with a bunch of dependency errors. In an attempt to find the problem, I've tried installing each dependency individually with, e.g., npm install react, but the command ignores the single argument and instead gives the same errors as trying to install the entire project. In desperation I tried the example from https://docs.npmjs.com/cli/v8/commands/npm-install: 'npm install sax`, where sax has nothing to do with the project, and it still fails.
package.json is:
{
"name": "graphiql-explorer-example",
"homepage": "https://onegraph.github.io/graphiql-explorer-example",
"version": "0.1.0",
"private": true,
"dependencies": {
"graphiql": "^0.12.0",
"graphql": "^14.1.1",
"graphiql-explorer": "^0.6.2",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-scripts": "2.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"flow": "flow",
"deploy": "gh-pages -d build",
"predeploy": "yarn build",
"prettier": "prettier --write \"src/**/*.js\" \"docs/**/*.md\" README.md"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"flow-bin": "^0.91.0",
"gh-pages": "^2.0.1"
},
"description": "Example usage of [OneGraph](https://www.onegraph.com)'s open source [GraphiQL explorer](https://github.com/OneGraph/graphiql-explorer).",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/OneGraph/graphiql-explorer-example.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/OneGraph/graphiql-explorer-example/issues"
}
}
The error messages are:
> npm install react
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: graphiql-explorer-example#0.1.0
npm ERR! Found: graphql#14.1.1
npm ERR! node_modules/graphql
npm ERR! graphql#"^14.1.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer graphql#"^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0" from graphiql#0.12.0
npm ERR! node_modules/graphiql
npm ERR! graphiql#"^0.12.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
The log file (excluding a pile of "timing" and "silly" messages) is:
1 info using npm#8.8.0
2 info using node#v16.14.2
22 verbose title npm install sax
23 verbose argv "install" "sax"
41 http fetch GET 200 https://registry.npmjs.org/graphiql 144ms (cache revalidated)
43 http fetch GET 200 https://registry.npmjs.org/graphql 47ms (cache revalidated)
47 verbose stack Error: unable to resolve dependency tree
As you can see, npm parses the "sax" argument correctly on line 23, but then ignores it and tries to install graphiql instead.
How can I get npm to install a single package, such as the latest version of react, instead of trying to install all of the dependencies for graphiql-explorer?
the problem here is the peer dependencies of "sax"
there are some ways to avoid checking peer dependency.
Method 1
npm install <package name> --force
or
npm install <package name> --legacy-peer-deps
but it is not recommended,
Adding --legacy-peer-deps to your npm installation will bypass peerDependency auto-installation, but this may result in conflicts due to potentially breaking changes
try to resove conflicts manually, by getting the peer dependency details using
npm info name-of-module peerDependencies
for more information refer: What does npm install --legacy-peer-deps do exactly? When is it recommended / What's a potential use case?
There is a fix for running the npm install command.
$ npm install
According to your error message when running the installation command:
npm ERR! ERESOLVE unable to resolve dependency tree
It states that some dependencies are incompatible with others. To fix this, you need to run the installation command with the following flag.
$ npm install --legacy-peer-deps
This should resolve the issue of the dependencies being incompatible with each other.
In conclusion, the issue was that the dependencies were incompatible with each other. However, there is a fix!
$ npm install --legacy-peer-deps

I am facing "npm run dev" missing script issues. How to resolve it?

I am currently in the folder E:\Learn\app-code-vue
E:\Learn\app-code-vue>npm run dev
npm ERR! Missing script: "dev"
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\Shrikant Rana\AppData\Local\npm-cache\_logs\2022-01-24T14_
26_36_332Z-debug.log
See the scripts that are configured with Vue CLI 3 in the package.json file
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint" },
so you can run by use this : npm run serve
Check your package.json file and see if you have dev named in your "scripts" key. This is what your package.json script tag should look like if you want to run a dev command:
"scripts": {
"start": "node index.js",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
use npm run serve
It's working for me
You may need to check if you are really in the correct folder

Error in running nuxt project: "'nuxt' is not recognized as an internal or external command"

When I tried to run npm run dev in my nuxt project, my console returned this message:
'nuxt' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! andromeda#1.0.0 dev: `nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the andromeda#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I solved this problem.
I was looking in stackoverflow for similar problems and apparently the problem was the npm cache.
I will let a link bellow with the solution and a quick sample of what i did.
Link to the answer:
npm ERR! code ELIFECYCLE
Step 1: npm cache clean --force
Step 2: Delete node_modules by $ rm -rf node_modules folder or delete
it manually by going into the directory and right-click > delete.
Delete package-lock.json file too.
Step 3: npm install
To start again, npm start
Thanks everyone who take time to help, really appreciate.
Make sure nuxt is installed in your Nuxt project:
$ cd /path/to/nuxt-project
$ npm list nuxt
nuxt-project#1.0.0 /path/to/nuxt-project
└── nuxt#2.6.3
Here /path/to/nuxt-project contains your package.json and node-modules.
If it isn't installed, add nuxt to your project by doing:
$ npm install --save nuxt
Or put it in your project's package.json then do npm install:
"dependencies": {
"nuxt": "^2.0.0"
},
UPDATE:
If you are still getting "nuxt not recognized" problems, try to use explicit path to nuxt from your node_modules directory.
Given this directory (after doing npm install --save nuxt):
nuxt-project
|- node_modules
|- .bin
|- nuxt
|- package.json
Update the dev command in package.json with:
"scripts": {
"dev": "node_modules/.bin/nuxt"
},
Sometimes this blows up because you're not exporting node_modules/.bin directory.
Place or append the following line in your .bashrc or .zshrc:
export PATH=node_modules/.bin:$PATH
Have the same problem recently.
Solution for me was change the path of scripts section in package.json from this:
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
to that:
"scripts": {
"dev": "node_modules/.bin/nuxt",
"build": "node_modules/.bin/nuxt build",
"start": "node_modules/.bin/nuxt start",
"generate": "node_modules/.bin/nuxt generate"
},
Step 1: rm -rf node_modules package-lock.json
Step 2: npm cache clean --force
Step 3: npm install ( you may need to add --legacy-peer-deps or --force flag, if npm install is not working )
To start again, npm start
To make build, npm run build (ssr ) or generate ( csr )
Install globally cross-env:
npm install -g cross-env
Then just update package.json scripts to start with "cross-env ...."
example:
"scripts": {
"dev": "cross-env nuxt",
"build": "cross-env nuxt build",
"start": "cross-env nuxt start",
"generate": "cross-env nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore ."
},
This works on my Windows 10.
It simply means nuxt is not installed.
Try running npm install nuxt

Package.json missing script: stg

Using codeship to deploy to aws. Got error like
npm ERR! missing script: stg
custom script
git clone https://${GITHUB_KEY}#github.com/me/myproject.git
ls
cd myproject
composer install --no-interaction --prefer-dist
nvm install 6.9.4
npm install sync-exec
npm install
npm rebuild node-sass
npm run stg
partial webpack
"scripts": {
"clean": "rimraf public/dist",
"watch": "webpack --config webpack.dev.config.js --watch --progress",
"dev": "webpack --config webpack.dev.config.js --progress",
"prod": "cross-env npm run clean && NODE_ENV=production webpack --config webpack.config.js --progress --profile --colors",
"stg": "cross-env npm run clean && NODE_ENV=stage webpack --config webpack.dev.config.js --progress --profile --colors",
"lint": "eslint ./app/**/**.js"
},
codeship error
npm run stgnpm ERR! Linux 4.15.0-1009-aws
npm ERR! argv "/home/rof/.nvm/versions/node/v6.9.4/bin/node" "/home/rof/.nvm/versions/node/v6.9.4/bin/npm" "run" "stg"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! missing script: stg
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /home/rof/src/github.com/myaccountname/myproject/myproject/npm-debug.log