运行 安装 angular2-notifications 后 lint 失败
Running lint fails after installing angular2-notifications
我最近使用 Angular-CLI 创建了一个新的 Angular4 项目。
我遇到的问题是在安装 angular2-notifications 之后,运行 ng lint
命令时出现错误。
错误:
Failed to load C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\angular2-notifications\tslint.json: Could not find custom rule directory: C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\angular2-notifications\node_modules\codelyzer
堆栈跟踪:
at new FatalError (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\tslint\lib\error.js:40:23)
at Object.findConfiguration (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\tslint\lib\configuration.js:47:15)
at files.forEach (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\tasks\lint.js:36:50)
at Array.forEach (native)
at lintConfigs.map (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\tasks\lint.js:30:19)
at Array.map (native)
at Class.run (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\tasks\lint.js:21:14)
at Class.run (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\commands\lint.js:45:25)
at Class.Command.validateAndRun (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\ember-cli\lib\models\command.js:128:15)
at C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\ember-cli\lib\cli\cli.js:92:22
我已经求助于 Google 来解决这个问题,但没有成功。我去过 GitHub repo 也没有运气。
然后我进入了 angular2-notifications 包的实际 tslint.json
文件。
我在顶部看到这个 :
"rulesDirectory": [
"node_modules/codelyzer"
],
当我删除那 3 行时,ng lint
命令起作用。
我的问题是,我在这里遗漏了什么吗?我需要这个命令才能工作,我认为修改包不是一个可以接受的解决方案。这是我应该向他们报告的包本身的错误吗?
谢谢
从 angular-cli.json 中的 lint 配置中排除 node_modules:
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**/*"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**/*"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**/*"
}]
angular2-notifications 项目显然不应该为用户破坏 ng lint。尽管如此,我想说一个项目不应该尝试检查不应该编辑的代码也有点公平。
我收到消息的原因是缺少 node_modules
目录。我运行npm install
之后问题就消失了
我遇到了同样的问题,我通过为 node_modules 提供正确的路径找到了解决方案。
我的意思是我的项目是 ASP.net 和 Angular - 其中目录结构是自定义的,“package.json”保存在 angular 应用程序之外,因此 node_modules 也驻留在“package.json”所在的同一目录中。
所以我能够通过将 tslint.ts 中的“node_modules”路径更改为
来解决这个问题
"rulesDirectory": [
"./../node_modules/codelyzer"
],
我最近使用 Angular-CLI 创建了一个新的 Angular4 项目。
我遇到的问题是在安装 angular2-notifications 之后,运行 ng lint
命令时出现错误。
错误:
Failed to load C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\angular2-notifications\tslint.json: Could not find custom rule directory: C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\angular2-notifications\node_modules\codelyzer
堆栈跟踪:
at new FatalError (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\tslint\lib\error.js:40:23)
at Object.findConfiguration (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\tslint\lib\configuration.js:47:15)
at files.forEach (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\tasks\lint.js:36:50)
at Array.forEach (native)
at lintConfigs.map (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\tasks\lint.js:30:19)
at Array.map (native)
at Class.run (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\tasks\lint.js:21:14)
at Class.run (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\commands\lint.js:45:25)
at Class.Command.validateAndRun (C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\ember-cli\lib\models\command.js:128:15)
at C:\Users\Gabriel\Documents\GitHub\Go-NoGo\GoNoGo\node_modules\@angular\cli\ember-cli\lib\cli\cli.js:92:22
我已经求助于 Google 来解决这个问题,但没有成功。我去过 GitHub repo 也没有运气。
然后我进入了 angular2-notifications 包的实际 tslint.json
文件。
我在顶部看到这个 :
"rulesDirectory": [
"node_modules/codelyzer"
],
当我删除那 3 行时,ng lint
命令起作用。
我的问题是,我在这里遗漏了什么吗?我需要这个命令才能工作,我认为修改包不是一个可以接受的解决方案。这是我应该向他们报告的包本身的错误吗?
谢谢
从 angular-cli.json 中的 lint 配置中排除 node_modules:
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**/*"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**/*"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**/*"
}]
angular2-notifications 项目显然不应该为用户破坏 ng lint。尽管如此,我想说一个项目不应该尝试检查不应该编辑的代码也有点公平。
我收到消息的原因是缺少 node_modules
目录。我运行npm install
之后问题就消失了
我遇到了同样的问题,我通过为 node_modules 提供正确的路径找到了解决方案。
我的意思是我的项目是 ASP.net 和 Angular - 其中目录结构是自定义的,“package.json”保存在 angular 应用程序之外,因此 node_modules 也驻留在“package.json”所在的同一目录中。
所以我能够通过将 tslint.ts 中的“node_modules”路径更改为
来解决这个问题"rulesDirectory": [
"./../node_modules/codelyzer"
],