简体   繁体   中英

I am using a CEAN app. Following errors appear when I am trying to run npm start for angular:

My app was working fine but suddenly started getting these errors for angular after I installed some modules for express server. After installation of those modules like

"bcryptjs": "*",
"connect-flash": "*",
"cookie-parser": "^1.4.3",
"express-messages": "*",
"express-session": "*",
"express-validator": "*",
"passport": "*",
"passport-http": "*",
"passport-local": "*"

express server is running fine but why I am getting these errors in Angular when I have not added or modified any package. I don't think they are related then why suddenly I started getting these errors:

> tsc -p src/

../node_modules/@types/bluebird/index.d.ts(50,17): error TS1005: ',' expected.
../node_modules/@types/bluebird/index.d.ts(50,31): error TS1005: ',' expected.
../node_modules/@types/bluebird/index.d.ts(1079,59): error TS1005: ']' expected.
../node_modules/@types/bluebird/index.d.ts(1079,60): error TS1005: ';' expected.
../node_modules/@types/bluebird/index.d.ts(1079,61): error TS1128: Declaration or statement expected
.
../node_modules/@types/bluebird/index.d.ts(1079,81): error TS1109: Expression expected.
../node_modules/@types/bluebird/index.d.ts(1164,1): error TS1128: Declaration or statement expected.


npm ERR! Windows_NT 6.1.7601

=============================

Command: npm -v, Results : 4.2.0

Command: node -v, Results : v7.8.0

Command: tsc -v, Results : Version 2.3.4

=============================

Following files are attached for reference:

 1. Following are from npm Debug File Info generated when tried 'npm start':

    0 info it worked if it ends with ok
    1 verbose cli [ 'D:\\installedSoftwares\\nodejs\\node.exe',
    1 verbose cli   'D:\\installedSoftwares\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
    1 verbose cli   'start' ]
    2 info using npm@4.2.0
    3 info using node@v7.8.0
    4 verbose run-script [ 'prestart', 'start', 'poststart' ]
    5 info lifecycle myappclient@1.0.0~prestart: myappclient@1.0.0
    6 verbose lifecycle myappclient@1.0.0~prestart: unsafe-perm in lifecycle true
    7 verbose lifecycle myappclient@1.0.0~prestart: PATH: D:\installedSoftwares\nodejs\node_modules\npm\bin\node-gyp-bin;D:\installedSoftwares\wamp64\www\test\work\integration7\client\node_modules\.bin;C:\Users\admin\AppData\Roaming\npm;D:\installedSoftwares\nodejs\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\installedSoftwares\nodejs\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Skype\Phone\;C:\Python27;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Brackets\command;C:\Users\admin\AppData\Local\atom\bin;C:\Users\admin\AppData\Roaming\npm;C:\Program Files (x86)\Microsoft VS Code\bin;D:\installedSoftwares\curl;D:\installedSoftwares\Couchbase\Server\bin
    8 verbose lifecycle myappclient@1.0.0~prestart: CWD: D:\installedSoftwares\wamp64\www\test\work\integration7\client
    9 silly lifecycle myappclient@1.0.0~prestart: Args: [ '/d /s /c', 'npm run build' ]
    10 silly lifecycle myappclient@1.0.0~prestart: Returned: code: 2  signal: null
    11 info lifecycle myappclient@1.0.0~prestart: Failed to exec prestart script
    12 verbose stack Error: myappclient@1.0.0 prestart: `npm run build`
    12 verbose stack Exit status 2
    12 verbose stack     at EventEmitter.<anonymous> (D:\installedSoftwares\nodejs\node_modules\npm\lib\utils\lifecycle.js:279:16)
    12 verbose stack     at emitTwo (events.js:106:13)
    12 verbose stack     at EventEmitter.emit (events.js:194:7)
    12 verbose stack     at ChildProcess.<anonymous> (D:\installedSoftwares\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
    12 verbose stack     at emitTwo (events.js:106:13)
    12 verbose stack     at ChildProcess.emit (events.js:194:7)
    12 verbose stack     at maybeClose (internal/child_process.js:899:16)
    12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
    13 verbose pkgid myappclient@1.0.0
    14 verbose cwd D:\installedSoftwares\wamp64\www\test\work\integration7\client
    15 error Windows_NT 6.1.7601
    16 error argv "D:\\installedSoftwares\\nodejs\\node.exe" "D:\\installedSoftwares\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
    17 error node v7.8.0
    18 error npm  v4.2.0
    19 error code ELIFECYCLE
    20 error errno 2
    21 error myappclient@1.0.0 prestart: `npm run build`
    21 error Exit status 2
    22 error Failed at the myappclient@1.0.0 prestart script 'npm run build'.
    22 error Make sure you have the latest version of node.js and npm installed.
    22 error If you do, this is most likely a problem with the myappclient package,
    22 error not with npm itself.
    22 error Tell the author that this fails on your system:
    22 error     npm run build
    22 error You can get information on how to open an issue for this project with:
    22 error     npm bugs myappclient
    22 error Or if that isn't available, you can get their info via:
    22 error     npm owner ls myappclient
    22 error There is likely additional logging output above.
    23 verbose exit [ 2, true ]

 2. Following snippet is for package.json_forAngular

    {
      "name": "myappclient",
      "version": "1.0.0",
      "description": "QuickStart package.json from the documentation, supplemented with testing support",
      "scripts": {
        "build": "tsc -p src/",
        "build:watch": "tsc -p src/ -w",
        "build:e2e": "tsc -p e2e/",
        "serve": "lite-server -c=bs-config.json",
        "serve:e2e": "lite-server -c=bs-config.e2e.json",
        "prestart": "npm run build",
        "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
        "pree2e": "npm run build:e2e",
        "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
        "preprotractor": "webdriver-manager update",
        "protractor": "protractor protractor.config.js",
        "pretest": "npm run build",
        "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
        "pretest:once": "npm run build",
        "test:once": "karma start karma.conf.js --single-run",
        "lint": "tslint ./src/**/*.ts -t verbose"
      },
      "keywords": [],
      "author": "",
      "license": "MIT",
      "dependencies": {
        "@angular/common": "~2.4.0",
        "@angular/compiler": "~2.4.0",
        "@angular/core": "~2.4.0",
        "@angular/forms": "~2.4.0",
        "@angular/http": "~2.4.0",
        "@angular/platform-browser": "~2.4.0",
        "@angular/platform-browser-dynamic": "~2.4.0",
        "@angular/router": "~3.4.0",
        "@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.25",
        "angular-in-memory-web-api": "~0.2.4",
        "angular2-google-chart": "^2.3.0",
        "core-js": "^2.4.1",
        "postcss-loader": "^2.0.1",
        "raw-loader": "^0.5.1",
        "rxjs": "5.0.1",
        "sass-loader": "^6.0.3",
        "systemjs": "0.19.40",
        "zone.js": "^0.7.4"
      },
      "devDependencies": {
        "concurrently": "^3.2.0",
        "lite-server": "^2.2.2",
        "typescript": "*",
        "canonical-path": "0.0.2",
        "tslint": "^3.15.1",
        "lodash": "^4.16.4",
        "jasmine-core": "~2.4.1",
        "karma": "^1.3.0",
        "karma-chrome-launcher": "^2.0.0",
        "karma-cli": "^1.0.1",
        "karma-jasmine": "^1.0.2",
        "karma-jasmine-html-reporter": "^0.2.2",
        "protractor": "~4.0.14",
        "rimraf": "^2.5.4",
        "@types/node": "*",
        "@types/jasmine": "2.5.36"
      },
      "repository": {}
    }

 3. Following are from package.json forExpress


    {
      "name": "myapp",
      "version": "1.0.0",
      "description": "A Couchbase, Express, Angular 2, & NodeJS (CEAN) app",
      "main": "server.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "devstart": "nodemon server.js"
      },
      "author": "",
      "license": "ISC",
      "dependencies": {
        "bcryptjs": "*",
        "body-parser": "^1.16.1",
        "connect-flash": "*",
        "cookie-parser": "^1.4.3",
        "couchbase": "^2.3.3",
        "debug": "^2.6.6",
        "ejs": "^2.5.5",
        "express": "^4.14.1",
        "express-messages": "*",
        "express-session": "*",
        "express-validator": "*",
        "mongojs": "^2.4.0",
        "morgan": "^1.8.1",
        "nodemon": "^1.11.0",
        "passport": "*",
        "passport-http": "*",
        "passport-local": "*",
        "request": "^2.81.0",
        "serve-favicon": "^2.4.2"
      },
      "devDependencies": {
        "nodemon": "^1.11.0"
      }
    }

============================================= 

I have already tried following:

  1. Removed 'node_modules' folder and installed packages again using 'npm install'
  2. Modified version of "@types/node" to latest
  3. Modified version of "typescript" to "*", "2.3.0", "^2.3"

Thanks for your help.

After some investigation I understood that the problem occurred because I had installed some libraries for Server. After careful installation of modules, I came to know that express-validator has following dependencies:

`-- express-validator@3.2.1
  +-- @types/bluebird@3.5.8
  +-- @types/express@4.0.36
  | +-- @types/express-serve-static-core@4.0.49
  | | `-- @types/node@8.0.13
  | `-- @types/serve-static@1.7.31
  |   `-- @types/mime@1.3.1
  +-- bluebird@3.5.0
  +-- lodash@4.17.4
  `-- validator@6.2.1

Therefore express-validator added bluebird which was causing issue with typescript. After my further research I understood that I need to use typescript "2.3.2". Therefore, I also modified and installed typescript version "2.3.2" for angular.

Now my problem got resolved but still I have a question.

Why client(Angular/Typescript) is causing problem for a module which is installed for Server(Express) because both of them have their own node_modules folders? How are they related? May be its a trivial question, but I lack this concept.

Thanks in advance for a detailed answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM