3.15.12.0.6If i type `tslint --project .' it works:
...
src/core/app.ts[1, 33]: ' should be "
src/core/app.ts[3, 26]: ' should be "
src/core/app.ts[4, 27]: ' should be "
src/core/app.ts[5, 29]: ' should be "
src/core/app.ts[7, 21]: ' should be "
src/core/app.ts[7, 30]: ' should be "
src/core/app.ts[27, 22]: ' should be "
src/core/app.ts[28, 23]: ' should be "
src/core/app.ts[1, 62]: Missing semicolon
src/core/app.ts[3, 35]: Missing semicolon
src/core/app.ts[4, 37]: Missing semicolon
src/server.ts[1, 21]: ' should be "
src/server.ts[2, 17]: ' should be "
src/server.ts[1, 33]: Missing semicolon
If i run the same command with an npm script i get:
me@me-ubu-N3355SL:~/project/server$ npm run lint
> [email protected] lint /project/server
> tslint --project '.'
Usage: /usr/bin/nodejs ./node_modules/.bin/tslint [options] [file ...]
Options:
-c, --config configuration file
-h, --help display detailed help
-i, --init generate a tslint.json config file in the current working directory
-o, --out output file
-r, --rules-dir rules directory
-s, --formatters-dir formatters directory
-e, --exclude exclude globs from path expansion
-t, --format output format (prose, json, verbose) [default: "prose"]
--test test that tslint produces the correct output for the specified directory
-v, --version current version
Missing files
npm ERR! Linux 4.8.0-26-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "lint"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! [email protected] lint: `tslint --project '.'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] lint script 'tslint --project '.''.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tslint --project '.'
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs server
npm ERR! Or if that isn't available, you can get their i...
And this is what i get in my npm-debug.log
13 info lifecycle [email protected]~lint: Failed to exec lint script
14 verbose stack Error: [email protected] lint: `tslint --project '.'`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:877:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
can you try running tslint --project '.' on the command line?
try editing your package.json file to not use the single quotes?
does it work with an absolute path?
tslint --project '.' works on the command line.
"lint": "tslint --project .", this and "lint": "tslint --project '.'", do not work using npm run lint
I have used pwd to determine the fullpath of my project and also tried:
npm run lint with lint script as "lint": "tslint --project fullpath/", and it did not work either.
I just noticed that the help text doesn't include --project. You're running an old version of tslint when running with npm, which doesn't support that option. I'm guessing that you have one version installed globally and a different one in node_modules
@nchen63 I confirmed that it was not the case.
Found something new and it was very odd
root@.../.../...# npm install typescript -g
/usr/bin/tsc -> /usr/lib/node_modules/typescript/bin/tsc
/usr/bin/tsserver -> /usr/lib/node_modules/typescript/bin/tsserver
/usr/lib
└── [email protected]
root@.../.../...# npm install -g tslint
/usr/bin/tslint -> /usr/lib/node_modules/tslint/bin/tslint
/usr/lib
├── [email protected]
└── UNMET PEER DEPENDENCY typescript@>=1.7.3
@bertolo1988 that looks like https://github.com/palantir/tslint/issues/1003
@bertolo1988 Try changing your lint script to npm -v and see what version it says
@nchen63
npm run lint
> npm -v
gives: 3.10.8, same as npm -v
Notice that people with #1003 can still use tslint...i can't.
the reason I ask is because you listed 3.15.1 in your bug report. the --project flag was introduced in 3.14.0
ah, sorry, can you run tslint -v, not npm -v in your script
3.15.1
well, I don't know what to say. Your help text does not give the --project option, so something is wrong with the version
Haven't seen such problem, but I can guess only next options to try at first:
node_modules folder to PATH variable, so there can be differences)../node_modules/.bin/tslint -v and ./node_modules/.bin/tslint --project "." in console."lint": "tslint --project \".\"" ) instead of single quotes in npm scripts."lint": "tslint --project \"tsconfig.json\"" in npm scripts.npm i typescript@2 tslint@next"lint": "tslint --project \".\""npm run lintI removed my global installation. Now i cannot run tslint on my console. I installed it locally and the version inside is "_id": "[email protected]",.
If i try to run tslint -v on my console it fails. That is ok i am expecting this since i dont have it globally installed.
If i set a npm script such as "lint":"npm -v" i get:
me@me-ubu-N55SL:~/path/sticky-notes$ npm run lint
[email protected] lint /path/sticky-notes
tslint -v
3.15.1
I think that only the global installation should allow me to run tslint. Installed as a npm module, it would only be accessible by using require/import.
IMPORTANT: Running tslint globally works well, when installed locally and running as an npm script i get this error
@bertolo1988 does it works as expected now?
If yes - glad that your problem is solved.
@IllusionMH No wait. i "isolated" the problem a bit better. There is a problem still. Check my previous comment.
@bertolo1988 if I understand correctly - you've managed to install 3.15.1 to the project (which was root case for problem with --project flag).
I've checked link with log output from your previous comment and everything is works as expected.
In short - this is just NPM detailed reaction on exit code when there are lint errors.
For more details and options check this thread https://github.com/palantir/tslint/issues/1704
P.S. To be sure that you run same package version as your build tools and CI - I personally prefer to use npm scripts or use packages from local installations like ./node_modules/.bin/tslint --project "." in your case
I just confirmed that if there are no lint errors, it ends the execution just fine.
I think that you should place a big warning in the repo readme for this because most of people will most likely run tslint with a npm script and get confused with the errors, just like me.
Thanks alot for your help. ;)
Just spent half an hour fighting this issue. You should really add the warning somewhere about this use case, cause it's really a standard now to call such scripts using npm run ....
Just ran into this issue and had to dig this up, posting for posterity. I personally didn't like my npm script failing when the linting failed, so I made this adjustment:
"lint:be": "./node_modules/.bin/tslint --project 'server' -t stylish || echo",
As written, this will never fail. Use with caution. I just personally couldn't stand the huge NPM error messages.
Alternatively, using yarn instead of npm also "fixes" this issue.
"lint": "yarn run lint:be",
"lint:be": "./node_modules/.bin/tslint --project 'server' -t stylish",
🤖 Beep boop! 👉 TSLint is deprecated 👈 and you should switch to typescript-eslint! 🤖
🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋
Most helpful comment
I just confirmed that if there are no lint errors, it ends the execution just fine.
I think that you should place a big warning in the repo readme for this because most of people will most likely run tslint with a npm script and get confused with the errors, just like me.
Thanks alot for your help. ;)