admin管理员组文章数量:1355529
In my project I'm trying to implement ESLint as part of a build process that is launched from an npm script.
I've got eslint and all of the plugins I need all installed as npm packages and I've got my .eslintrc file all setup. When I then run the mand ...
eslint src
... on a mac, everything works perfectly. I can therefore take that mand and stick it into an npm script and it works just fine.
However, on windows I'm experiencing a problem. When I install the eslint npm package I am unable to use eslint from the mand line. I see that it has installed in the node_modules directory and that it put the executable in the node_modules/.bin directory, but when I run the mand ...
eslint src
... I get an error saying that the eslint mand is not found.
I can get it to work if I install eslint and all of my plugins globally, but this isn't ideal because anyone else who clones my code will need to do that also. It's as if on windows, the mand line does not have a path mapped to node_modules/.bin.
I tried to solve this problem with this little trick :
PATH=$(npm bin):$PATH eslint src
When I run this mand directly from the mand line it seems to be able to find the eslint mand and everything works perfectly. However, when I place that same mand into an npm script, the script runs with no output and no error.
Any direction on how to get this working would be awesome. Thanks.
In my project I'm trying to implement ESLint as part of a build process that is launched from an npm script.
I've got eslint and all of the plugins I need all installed as npm packages and I've got my .eslintrc file all setup. When I then run the mand ...
eslint src
... on a mac, everything works perfectly. I can therefore take that mand and stick it into an npm script and it works just fine.
However, on windows I'm experiencing a problem. When I install the eslint npm package I am unable to use eslint from the mand line. I see that it has installed in the node_modules directory and that it put the executable in the node_modules/.bin directory, but when I run the mand ...
eslint src
... I get an error saying that the eslint mand is not found.
I can get it to work if I install eslint and all of my plugins globally, but this isn't ideal because anyone else who clones my code will need to do that also. It's as if on windows, the mand line does not have a path mapped to node_modules/.bin.
I tried to solve this problem with this little trick :
PATH=$(npm bin):$PATH eslint src
When I run this mand directly from the mand line it seems to be able to find the eslint mand and everything works perfectly. However, when I place that same mand into an npm script, the script runs with no output and no error.
Any direction on how to get this working would be awesome. Thanks.
Share Improve this question edited Feb 15, 2016 at 18:09 John Slegers 47.2k23 gold badges204 silver badges173 bronze badges asked Feb 15, 2016 at 18:03 jdavisjdavis 8,67514 gold badges55 silver badges63 bronze badges1 Answer
Reset to default 5If you configure your package.json
this way
{
"name": "test",
"version": "0.1.1",
"description": "Validate files with ESLint",
"scripts": {
"test": "eslint src"
},
"devDependencies": {
"eslint": "^2.0.0",
"eslint-config-ideal": "^0.1.0"
}
}
Now just run
npm install
and after that run
npm test
This is should work across OS.
Note: If you run eslint
directly then you need to install the eslint globally with npm install eslint -g
mand.
本文标签: javascriptRun ESLint from NPM script on WindowsStack Overflow
版权声明:本文标题:javascript - Run ESLint from NPM script on Windows - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744022217a2577415.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论