语法错误:参数列表后缺少 ) | 节点js | `npm 启动`

Bre*_*dan 5 node.js npm eslint

运行时npm start出现语法错误,如下面的输出所示。我知道如何修复简单的语法错误,但我怀疑这就是问题所在。浏览各种论坛并没有给我带来答案。

[nodemon] starting `npm run lint && node src/app.js`

> server@1.0.0 lint C:\Users\brend\project\server
> node ./node_modules/.bin/eslint **/*.js

C:\Users\brend\project\server\node_modules\.bin\eslint:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
      ^^^^^^^

SyntaxError: missing ) after argument list
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:383:7)
    at startup (bootstrap_node.js:149:9)

npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\ProgramFiles\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "lint"
npm ERR! node v6.11.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! server@1.0.0 lint: `node ./node_modules/.bin/eslint **/*.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the server@1.0.0 lint script 'node ./node_modules/.bin/eslint **/*.js'.
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 server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./node_modules/.bin/eslint **/*.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs server
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls server
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\brend\project\server\npm-debug.log
[nodemon] app crashed - waiting for file changes before starting...
Run Code Online (Sandbox Code Playgroud)

下面是package.json。

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node ./node_modules/nodemon/bin/nodemon.js src/app.js --exec \"npm run lint && node\" ",
    "lint": "node ./node_modules/.bin/eslint **/*.js"
  },
Run Code Online (Sandbox Code Playgroud)

Bre*_*dan 1

呃..好吧,我遇到的第一件事是一个错误说'.' is not recognized as an internal or external command。我用谷歌搜索并得出结论,我需要将其放在node脚本之前。这带来了进步;即它实际上运行了脚本。事实证明,脚本中需要它"start",但"lint"脚本中不需要。

我的 package.json 脚本现在如下所示:

"scripts": {
"start": "node ./node_modules/nodemon/bin/nodemon.js src/app.js --exec \"npm run lint && node\" ",
"lint": "./node_modules/.bin/eslint **/*.js"
},
Run Code Online (Sandbox Code Playgroud)

结果是:

[nodemon] starting `npm run lint && node src/app.js`

> server@1.0.0 lint C:\Users\brend\project\server
> eslint **/*.js

hello
[nodemon] clean exit - waiting for changes before restart
Run Code Online (Sandbox Code Playgroud)

ps:感谢各位好心的陌生人的帮助!