nodejs npm同时启动错误

时间:2017-07-29 10:41:38

标签: javascript node.js

我在package.json中有以下代码:

"scripts": {
        "start": "concurrently --kill-others \"npm run _server:run\" \"ng serve --aot --progress=false --proxy-config proxy.conf.json\"",
        "lint:client": "ng lint",
        "lint:server": "tslint './server/**/*.ts' -c ./server/tslint.json --fix",
        "test:client": "ng test",
        "e2e:client": "ng e2e",
        "build": "ng build --prod --sm=false --aot --output-path=dist/client && npm run _server:build",
        "_server:run": "tsc -p ./server && concurrently \"tsc -w -p ./server\" \"nodemon --debug dist/server/bin/www.js\" ",
        "_server:build": "tsc -p ./server",
        "postinstall": "npm run build"
    },

如果我跑:

  

npm run _server:run

一切正常,但如果我跑:

  

npm run start

我收到以下错误:

[0] [1] [0] 'np' n?o ? reconhecido como um comando interno ou externo,
[0] [1] [0] programa operacional ou ficheiro batch.
[0] [1] [2] A sintaxe do nome do ficheiro, do nome do direct?rio ou da etiqueta
do volume ? incorrecta.
[0] [1] [1] 'run' n?o ? reconhecido como um comando interno ou externo,
[0] [1] [1] programa operacional ou ficheiro batch.
[0] [1] [4] 'serve' n?o ? reconhecido como um comando interno ou externo,
[0] [1] [4] programa operacional ou ficheiro batch.
[0] [1] [1] run exited with code 1
[0] [1] --> Sending SIGTERM to other processes..
[0] [1] [2] _server:run" exited with code 1
[0] [1] [0] np exited with code 1
[0] [1] [3] 'n' n?o ? reconhecido como um comando interno ou externo,
[0] [1] [3] programa operacional ou ficheiro batch.
[0] [1] [4] serve exited with code 1
[0] [1] [3] n exited with code 1

我的窗户是葡萄牙语,所以有些部分是葡萄牙语,但实际上它说np程序无法识别。

我对nodejs很新,我认为是'同时'的事情,但我无法弄清楚是什么问题

修改

完整的package.json:

{
    "name": "dynamicflowweb",
    "version": "4.0.9",
    "scripts": {
        "start": "concurrently --kill-others \"npm run _server:run\" \"ng serve --aot --progress=false --proxy-config proxy.conf.json\"",
        "lint:client": "ng lint",
        "lint:server": "tslint './server/**/*.ts' -c ./server/tslint.json --fix",
        "test:client": "ng test",
        "e2e:client": "ng e2e",
        "build": "ng build --prod --sm=false --aot --output-path=dist/client && npm run _server:build",
        "_server:run": "tsc -p ./server && concurrently \"tsc -w -p ./server\" \"nodemon --debug dist/server/bin/www.js\" ",
        "_server:build": "tsc -p ./server",
        "postinstall": "npm run build"
    },
    "private": true,
    "dependencies": {
        "@agm/core": "^1.0.0-beta.0",
        "@angular/animations": "^4.0.0",
        "@angular/cli": "^1.2.4",
        "@angular/common": "^4.0.0",
        "@angular/compiler": "^4.0.0",
        "@angular/core": "^4.0.0",
        "@angular/forms": "^4.0.0",
        "@angular/http": "^4.0.0",
        "@angular/platform-browser": "^4.0.0",
        "@angular/platform-browser-dynamic": "^4.0.0",
        "@angular/router": "^4.0.0",
        "angular-bootstrap-md": "*",
        "angular2-jwt": "^0.2.3",
        "chart.js": "2.5.0",
        "classlist.js": "^1.1.20150312",
        "core-js": "^2.4.1",
        "easy-pie-chart": "^2.1.7",
        "font-awesome": "^4.7.0",
        "hammerjs": "^2.0.8",
        "jsonwebtoken": "^7.4.1",
        "rxjs": "^5.1.0",
        "screenfull": "^3.2.0",
        "web-animations-js": "^2.2.5",
        "webpack": "^2.2.0",
        "zone.js": "^0.8.4"
    },
    "devDependencies": {
        "@angular/cli": "1.0.0",
        "@angular/compiler-cli": "^4.0.0",
        "@types/jasmine": "2.5.38",
        "@types/node": "~6.0.60",
        "codelyzer": "~2.0.0",
        "concurrently": "^3.5.0",
        "jasmine-core": "~2.5.2",
        "jasmine-spec-reporter": "~3.2.0",
        "karma": "~1.4.1",
        "karma-chrome-launcher": "~2.0.0",
        "karma-cli": "~1.0.1",
        "karma-coverage-istanbul-reporter": "^0.2.0",
        "karma-jasmine": "~1.1.0",
        "karma-jasmine-html-reporter": "^0.2.2",
        "nodemon": "^1.11.0",
        "protractor": "~5.1.0",
        "ts-node": "~2.0.0",
        "tslint": "~4.5.0",
        "typescript": "~2.2.0"
    }
}

2 个答案:

答案 0 :(得分:0)

唯一适合我的方法是添加-原始,因此我使用

concurrently --raw "npm:task1" "npm:task2"

我不知道为什么它只能在这种组合下工作。这当然是npm的功能,因为我尝试的其他命令在没有原始标志的情况下也能完美工作。即以下将正常工作:

concurrently "tsc" "node-sass --output-style compressed index.scss ./out/index.css"

答案 1 :(得分:0)

您需要同时安装。

该工具是用 Node.js 编写的,但您可以使用它来运行任何命令。

npm install -g concurrently

或者如果你从 npm 脚本中使用它:

npm install concurrently --save

使用

记住用引号将单独的命令括起来:

concurrently "command1 arg" "command2 arg"

否则会尝试同时运行 4 个单独的命令:command1、arg、command2、arg。

在 package.json 中,转义引号:

"start": "concurrently \"command1 arg\" \"command2 arg\""

https://www.npmjs.com/package/concurrently