0

菜鸟在这里试图学习,我不确定我做错了什么。我有一个项目,我正在尝试启动本地服务器。但是,当我运行命令“npm start”时,出现以下错误

> node ./node_modules/node-static/bin/cli.js -H '{"Cache-Control": "no-cache, must-revalidate"}' ./public

undefined:1
'{Cache-Control:
^

SyntaxError: Unexpected token ' in JSON at position 0
    at Object.parse (native)
    at Object.<anonymous> (C:\Users\Sean\Documents\GitHub\test\node_modules\node-static\bin\cli.js:90:46)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Function.Module.runMain (module.js:575:10)
    at startup (node.js:160:18)
    at node.js:449:3

npm ERR! Windows_NT 10.0.19042
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.2.0
npm ERR! npm  v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! test@1.0.0 start: `node ./node_modules/node-static/bin/cli.js -H '{"Cache-Control": "no-cache, must-revalidate"}' ./public`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@1.0.0 start script 'node ./node_modules/node-static/bin/cli.js -H '{"Cache-Control": "no-cache, must-revalidate"}' ./public'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./node_modules/node-static/bin/cli.js -H '{"Cache-Control": "no-cache, must-revalidate"}' ./public
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs test
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls test
npm ERR! There is likely additional logging output above.

这是 package.json 中的内容

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node ./node_modules/node-static/bin/cli.js -H '{\"Cache-Control\": \"no-cache, must-revalidate\"}' ./public"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "node-static": "^0.7.10"
  },
  "engines": {
    "node": ">= 6.2.0"
  }
}

我知道这个问题很可能与这行的编写方式有关,但无法弄清楚它是什么:

"start": "node ./node_modules/node-static/bin/cli.js -H '{\"Cache-Control\": \"no-cache, must-revalidate\"}' ./public"

谢谢你。

4

0 回答 0