我可以使用nodemon来lint我的javascript吗?我没有使用任何构建工具,例如gulp或grunt,并且想要最大化节点和npm的使用.
nodemon的输出可以通过管道输出.我想使用它来使用eslint来修改已更改的文件.
这是我的package.json
{
"name": "app",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "nodemon server.js",
"lint": "eslint"
},
"dependencies": {
"MD5": "*",
"clean-css": "*",
"express": "~4.9.0",
"express-handlebars": "~2.0.1",
"express-redis-cache": "*",
"foundation-sites": "~5.5.3",
"fs-extra": "~0.8.1",
"node-rest-client": "~1.5.1",
"node-sass": "*",
"path": "*"
},
"devDependencies": {
"babel-eslint": "^4.1.6",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^2.1.1",
"eslint-config-airbnb-es5": "^1.0.8",
"eslint-plugin-react": "^3.13.1",
"nodemon": "~1.8.1",
"parallelshell": "~2.0.0",
"watch": "~0.17.1"
}
}Run Code Online (Sandbox Code Playgroud)
我试过这个.但它不起作用.它给出了错误.
"scripts": {
"start": "nodemon({ script: 'server.js' }).on('restart', function () {console.log('nodemon started');}).on('crash', function () {console.log('script crashed for some …Run Code Online (Sandbox Code Playgroud) module.exports = {
bail: true,
watch: true,
target: 'web',
entry: paths.allLibraryIndexJs,
output: {
path: paths.appLibraryBuild,
filename: '[name].app.js',
library: '[name]',
libraryTarget: 'umd',
publicPath: publicPath
},
externals: {
lodash: {
commonjs: 'lodash',
commonjs2: 'lodash',
amd: 'lodash',
root: '_'
},
react: {
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
root: 'React'
},
'props-types': {
commonjs: 'props-types',
commonjs2: 'props-types',
amd: 'props-types',
root: 'PropsTypes'
},
'react-dom': {
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'react-dom',
root: 'ReactDOM'
},
redux: {
commonjs: 'redux',
commonjs2: 'redux',
amd: 'redux',
root: 'redux' …Run Code Online (Sandbox Code Playgroud)当我们向用户发送短信时,我看到来自这个机器人的大量流量。我正在尝试获取有关此机器人的更多详细信息。任何描述它做什么、它有多重要以及我们可以阻止它的指针将不胜感激。完整的用户代理是
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 Google (+https://developers.google.com/+/web/snippet/)
我的理解是,在调用堆栈中任何地方抛出错误的代码都可以在最终的 catch 块中捕获。对于获取错误,当没有互联网可用时,当我在 callCallAPI 中创建 APIwithoutCatch 时,不会捕获错误。而 APIwithCatch 捕获它自己的错误。所有其他错误,例如 404,都会在我想要的任何地方捕获。
async function APIwithcatch() {
try {
var response = await fetch("http://wwww.dfdfdf.com/user.json");
return response;
} catch (e) {
console.log(e);
}
}
async function APIwithoutcatch() {
var response = await fetch("http://wwww.dfdfdf.com/user.json");
return response;
}
function callCallAPI() {
try {
// return APIwithcatch();
return APIwithoutcatch();
} catch (e) {
console.log(e);
}
}
callCallAPI();Run Code Online (Sandbox Code Playgroud)
javascript ×3
async-await ×1
babel-loader ×1
babeljs ×1
bots ×1
ecmascript-6 ×1
eslint ×1
fetch ×1
googlebot ×1
node.js ×1
nodemon ×1
npm ×1
promise ×1
try-catch ×1
webpack ×1