https://www.youtube.com/watch?v=Fa4cRMaTDUI
I am watching this lesson and trying to recreate everything author does. At 19:00 he sets vue.js-express.js project. He creates folder called 'server'. In 'server/' he runs 'npm init -f'. Then 'npm install --save nodemon eslint', then he inits eslint.
Then in package.json file he writes:
"scripts": {
"start": "nodemon src/app.js --exec 'npm run lint && node'",
"lint": "eslint **/*.js"
}
Then in folder 'server' he creates folder 'src'. In 'src' he creates 'app.js'. And in 'app.js; there is a simple console.log('hello').
Then he runs 'npm start'. 'Hello' is printed in terminal, nodemon and eslint works just fine. Then he types 'npm install --save express'. Thats where my problem begins. After installing express.js i type 'npm start' and i get this error in terminal:
Oops! Something went wrong! :(
ESLint: 5.0.0.
No files matching the pattern "node_modules/ipaddr.js" were found.
Please check for typing mistakes in the pattern.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! server#1.0.0 lint: `eslint **/*.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the server#1.0.0 lint 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! /home/r/.npm/_logs/2018-06-25T10_32_02_027Z-debug.log
[nodemon] process failed, unhandled exit code (2)
[nodemon] Error
at Bus.utils.bus.on (/home/r/projects/tab-tracker/server/node_modules /nodemon/lib/nodemon.js:148:25)
at Bus.emit (events.js:164:20)
at ChildProcess.<anonymous> (/home/r/projects/tab-tracker/server/node_modules/nodemon/lib/monitor/run.js:164:11)
at ChildProcess.emit (events.js:159:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
Why is this happening?
Quote the pattern and it works fine as in previous versions of eslint
"lint": "eslint \"**/*.js\""
Credit goes to
https://github.com/eslint/eslint/issues/10599
#joknawe in comments gave right answer, thanks.
edit:
Looks like maybe it is trying to lint your node_modules directory. This should be ignored by default, but your wildcard **/*.js may be causing the issue. Try just using eslint
Replace your code
"start": "nodemon src/app.js --exec 'npm run lint && node'",
"lint": "eslint **/*.js"
for
"start": "nodemon src/app.js --exec 'npm run lint && node'",
"lint": "eslint"
I use WSL and i fixed by changing following line.
Previous
"start": "./node_modules/nodemon/bin/nodemon.js src/app.js --exec 'npm run lint && node'",
"lint": "./node_modules/.bin/eslint **/*.js"
After
"start": "./node_modules/nodemon/bin/nodemon.js src/app.js --exec 'npm run lint && node'",
"lint": "./node_modules/.bin/eslint src/**/*.js --fix"
In a Mac I fixed it just changing the following line
Previous
"lint": ""lint": "./node_modules/.bin/eslint **/*.js""
After
"lint": "./node_modules/.bin/eslint src/*.js"
Just add quotes around the wildcard **/*.js.
"scripts": {
"start": "nodemon src/app.js --exec 'npm run lint && node'",
"lint": "eslint **/*.js"
}
in .eslint.js file you should replace this code
Before
"browser": true
After
"node": true
Related
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
i want to setup a script which should simple --fix all files like this:
"lint": "eslint --fix vue/**/*.vue && eslint --fix vue/**/*.js"
automatic lint all .vue and .js files inside a vue project.
this wont work unfort.
it gives me a:
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! project#1.0.0 lint: `eslint --fix vue/**/*.vue && eslint --fix vue/**/*.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the project#1.0.0 lint script.
anyone a idea?
Remove && and that should work. Make the command vue-cli-service lint only Vue CLI directory for .vue and .js. The resulting definition is:
"lint": "eslint --fix vue/**/*.vue vue/**/*.js"
package.json:
"devDependencies": {
"tailwindcss": "^0.7.4"
},
"scripts": {
"tailwind:css": "tailwind build src/css/tailwind.src.css -c tailwind.js -o src/css/tailwind.css",
"start": "npm run tailwind:css && react-scripts start",
"build": "npm run tailwind:css && react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
error:
sh: 1: tailwind: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! client#0.1.0 tailwind:css: `tailwind build src/css/tailwind.src.css -c tailwind.js -o src/css/tailwind.css`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the client#0.1.0 tailwind:css script.
Even though (in my experience) some heroku deployments seem to somehow get away with tailwind in the devDependencies, moving it into your dependencies does fix this issue.
This can affect more than just tailwind, so you might need to move more than just tailwind across for your build to work.
I am trying to setup angular2 on my local machine, I installed node and npm, after installing npm when I do 'npm start' I am getting below error
root#sameer-Vostro-2520:/home/sameer/angular2/angular-2-beta-boilerplate# npm start
> angular2-boilerplate#1.0.0 start /home/sameer/angular2/angular-2-beta-boilerplate
> concurrent "npm run gulp" "npm run lite"
sh: 1: concurrent: not found
npm ERR! weird error 127
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! not ok code 0
How can we fix this?
installed concurrent but again same error
concurrently#2.2.0 /root/.node/lib/node_modules/concurrently
├── commander#2.6.0
├── bluebird#2.9.6
├── cross-spawn#0.2.9 (lru-cache#2.7.3)
├── moment#2.14.1
├── rx#2.3.24
├── lodash#4.13.1
└── chalk#0.5.1 (supports-color#0.2.0, escape-string-regexp#1.0.5, ansi-styles#1.1.0, strip-ansi#0.3.0, has-ansi#0.1.0)
> angular2-boilerplate#1.0.0 start /home/sameer/angular2/angular-2-beta-boilerplate
> concurrent "npm run gulp" "npm run lite"
/usr/bin/env: node: No such file or directory
npm ERR! weird error 127
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! not ok code 0
This issue got fixed after installing nodejs-legacy
apt-get install nodejs-legacy
First run yarn and then npm start again
Someone who is having difficult running command in your package json file and getting error like
[0] /bin/sh: xxx: command not found
[1] /bin/sh: xxx: command not found
Solution -
Note You are running npm commands via npm so your command should use
npm:
Example -
if you got, following npm command
start, build, lint
You will have concurrently command like this
"scripts: {
"start": "ng start",
"build": "ng build",
"lint": "ng lint"
"run:all": "concurrently npm:start npm:build npm:lint"
}
See in above script usage of npm:
I have the following scripts in my package.json file
"scripts": {
"start": "watchify -o js/bundle.js -v -d .",
"build": "browserify . | uglifyjs -cm > js/bundle.min.js"
},
when i run npm build, the command executes and moves to a fresh new line in the terminal and the script has'nt been built.
To figure out the problem,
how can i get more verbose/debugging info from running this command?
Have you tried the following command?
npm build --verbose