You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用JSHint检测Hello World脚本时出现“Bad option: 'script'”错误求助

Fixing JSHint's "Bad option: 'script'" Error

Hey there! Let's get that JSHint error sorted out quickly. The problem here is a mix-up between JSHint configuration options and npm scripts—they belong in different places, and JSHint doesn't recognize a script option in its config.

Here's what went wrong:

You added the lint script directly into your JSHint config, but that's not where npm scripts live. JSHint's config should only contain rules/settings related to code linting, not command-line scripts.

Step 1: Fix your JSHint config

Remove the "script" key entirely. Your corrected JSHint config (either in .jshintrc or the relevant section) should look like this:

{ 
  "browser": true, 
  "browserify": true, 
  "devel": true 
}

Step 2: Move the lint script to package.json

The lint command belongs in the scripts field of your package.json. Update your package.json to include it properly:

{ 
  "name": "myangular", 
  "version": "1.0.0", 
  "scripts": {
    "lint": "jshint src"
  },
  "devDependencies": { 
    "jshint": "^2.9.5" 
  } 
}

Why this works:

  • JSHint uses its config to know how to analyze your code (like enabling browser-specific globals with browser: true).
  • npm uses the scripts field to store reusable commands—now you can run npm run lint to trigger JSHint on your src folder, and JSHint won't throw that invalid option error anymore.

Give it a test run, and that error should be gone!

内容的提问来源于stack exchange,提问作者Xiaolin Lan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:53:27