参数列表|后面的SyntaxError:missing) nodejs | `npm start`

时间:2017-10-14 21:08:15

标签: 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...

下面是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"
  },

1 个答案:

答案 0 :(得分:1)

呃..好的,我遇到的第一件事是'.' is not recognized as an internal or external command的错误。我用Google搜索并得出结论,我需要在脚本之前放置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"
},

结果是:

[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

ps:谢谢你的陌生人的帮助!