【问题标题】:Running "npm run dev" on pet-shop-project fails and gives errors在 pet-shop-project 上运行“npm run dev”失败并给出错误
【发布时间】:2018-05-31 19:23:06
【问题描述】:

嗨,每当我尝试在终端上运行 npm run dev pet-shop-project 教程时,它会在错误下方出现一长串错误。 希望能在您的帮助下解决问题。

提前致谢。

PS C:\pet-shop-tutorial> npm run dev

> pet-shop@1.0.0 dev C:\pet-shop-tutorial
> lite-server

npm : C:\Users\Ali\AppData\Roaming\npm\node_modules\lite-server\lib\lite-server.js:33
At line:1 char:1
+ npm run dev
+ ~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (C:\Users\Ali\Ap...te-server.js:33:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

      throw (err);
      ^
SyntaxError: C:\pet-shop-tutorial\bs-config.json: Unexpected token } in JSON at position 70
    at JSON.parse (<anonymous>)
    at Object.Module._extensions..json (module.js:671:27)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at start (C:\Users\Ali\AppData\Roaming\npm\node_modules\lite-server\lib\lite-server.js:28:17)
    at Object.<anonymous> (C:\Users\Ali\AppData\Roaming\npm\node_modules\lite-server\bin\lite-server:7:30)
    at Module._compile (module.js:652:30)
npm

ERR!

code
 ELIFECYCLE
npm

ERR!

errno
 1
npm

ERR!
 pet-shop@1.0.0 dev: `lite-server`
npm

ERR!
 Exit status 1
npm

ERR!

npm

ERR!
 Failed at the pet-shop@1.0.0 dev script.
npm

ERR!
 This is probably not a problem with npm. There is likely additional logging output above.
npm

ERR!
 A complete log of this run can be found in:
npm

ERR!


     C:\Users\Ali\AppData\Roaming\npm-cache\_logs\2018-05-30T01_41_54_260Z-debug.log

bs-config-json 内容

 {
  "server": {
    "baseDir": ["./src", "./build/contracts"],

  }
}

【问题讨论】:

  • 可以发bs-config.json的内容吗?它包含语法错误。
  • 您好{"server": { "baseDir": ["./src", "./build/contracts"], } }

标签: solidity


【解决方案1】:

bs-config.json 的内容不是有效的 JSON。数组后有一个额外的逗号。它应该是这样的:

{ "server": { "baseDir": ["./src", "./build/contracts"] } }

这就是您收到此错误的原因:

SyntaxError: C:\pet-shop-tutorial\bs-config.json: Unexpected token } in JSON at position 70

您可以使用像 https://jsonlint.com/ 这样的 JSON 验证器来验证您的 JSON。

【讨论】:

    猜你喜欢
    • 2021-08-12
    • 2018-02-26
    • 2018-12-12
    • 2019-03-18
    • 2020-12-27
    • 2017-12-28
    • 2023-02-02
    • 2019-01-09
    • 2020-10-12
    相关资源
    最近更新 更多