S
S
Senseich2019-08-19 09:54:04
JSON
Senseich, 2019-08-19 09:54:04

How to write json correctly?

Hello!
I'm learning webpack and I want to connect the node-static plugin so that it passes parameters to headers. I follow the instructions as here: (at the very end) https://github.com/cloudhead/node-static
This is how I write it in my package.json

{
  "name": "webpack-app",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "start": "webpack --mode production --watch",
    "dev": "webpack --mode development",
    "serv": "static -H '{"Cache-Control": "no-cache, must-revalidate"}'" // Данная строка
  },
  "devDependencies": {
    "html-webpack-plugin": "^3.2.0",
    "node-static": "^0.7.11",
    "webpack": "^4.39.2",
    "webpack-cli": "^3.3.6"
  }
}

But the editor swears and an error occurs when starting ... then I escaped the double quotes
"serv": "static -H '{\"Cache-Control\": \"no-cache, must-revalidate\"}'"

Gives an error message
undefined:1
'{Cache-Control:
^
SyntaxError: Unexpected token ' in JSON at position 0
........

Tried double quotes instead of single quotes before "{"Cache-Control" ..... }"
undefined:1
{Cache-Control: no-cache,
 ^
SyntaxError: Unexpected token C in JSON at position 1

I understand that somewhere in the syntax there is an error, tell me how to write this line correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
3
3aiats, 2019-08-19
@3aiats

{
"name": "webpack-app",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "webpack --mode production --watch",
"dev": "webpack --mode development",
"serv": "static -H \"{\"Cache-Control\": \"no-cache, must-revalidate\ "}\""
},
"devDependencies": {
"html-webpack-plugin": "^3.2.0",
"node-static": "^0.7.11",
"webpack": "^4.39.2" ,
"webpack-cli": "^3.3.6"
}
}
in the future I recommend using an editor like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question