node.js - npm run "script"不执行任何操作

标签 node.js npm

这真的很奇怪,我的 package.json 中有以下脚本:

"scripts": {
   "lint": "./node_modules/tslint/bin/tslint src/js/**/*",
   "lint:fix": "./node_modules/tslint/bin/tslint src/js/**/* --fix"
},

当我运行npm run lint时我没有收到任何错误并运行 echo $?演出后立即 0

但是,如果我运行 tslint src/js/**/*我确实遇到了 linting 错误。

怎么会这样?

最佳答案

由于使用通配符,npm 中存在许多众所周知的问题。其中许多仅影响 Windows,而其他则“仅”特定于 shell。

尝试以下操作。

"scripts": {
   "lint": "./node_modules/tslint/bin/tslint \"src/**/*.ts\"",
},

如果这没有立即让您相信计算机对人类来说是一场灾难,您可以在奇妙的 The Linux Programming Interface 中详细了解为什么这些问题会发生。 ,其中涵盖了数量惊人的非 Linux 可移植性问题,例如这个问题。

关于node.js - npm run "script"不执行任何操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45048195/

相关文章:

node.js - 我的应用程序已成功部署在 Azure 中,但无法访问 URL

Javascript:具有多个查询参数的嵌套 JSON api 请求

node.js - npm 是否使用 package.json 中定义的 npm?

javascript - 当使用 webpack 等将所有内容打包到一个脚本中时,Npm、Dev 依赖还是依赖?

javascript - 为什么在 JavaScript 注释中使用 '@' - @param

node.js - 如何在 VueJS 上制作图表

node.js - 运行 npm 命令时出错

node.js - 更改 Windows 中 node.js 模块的默认全局安装目录?

npm - json-server 我们可以使用其他键而不是 id 来发送和放置请求吗

npm - 为什么 “npm install” 更改 package-lock.json 并添加波浪号或上限?