Angular2 application install & run via package.jso

2019-07-11 08:03发布

问题:

My question is related to this question that was asked 4 days ago: (URL#1) How to start Angular2 project with minimum of required files using npm?

I use the same package.json that was mentioned in the above URL and I am doing the same project. I get the following errors, for which I think the solution is: (URL#2) https://github.com/npm/npm/issues/8048

However, I want confirmation from someone that I have identified correctly what the problem is that is causing these errors. I am in the process of implementing the suggestions in #URL2 to see if my problem vanishes. I am trying this out (i.e "npm start" command) both on Windows 7 & Windows 10 & getting error in both OS.

For your benefit here is the detailed list of errors: error Windows_NT 6.1.7601 error argv "C:\Program Files\nodejs\node.exe" "C:\Users\dev4\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "start" error npm v3.5.3 error code ELIFECYCLE error angular2-quickstart@1.0.0 start: concurrent "npm run tsc:w" "npm run lite" error Exit status 1 error Failed at the angular2-quickstart@1.0.0 start script 'concurrent "npm run tsc:w" "npm run lite" '. error Make sure you have the latest version of node.js and npm installed. error If you do, this is most likely a problem with the angular2-quickstart package, error not with npm itself. error Tell the author that this fails on your system: error concurrent "npm run tsc:w" "npm run lite" error You can get information on how to open an issue for this project with: error npm bugs angular2-quickstart error Or if that isn't available, you can get their info via: error npm owner ls angular2-quickstart error There is likely additional logging output above. verbose exit [ 1, true ]

Thank you for your time.

-Srikanth

回答1:

I'm not sure what solution you're referring to in that second (github) link, unless you mean you're working behind a proxy, and setting http_proxy correctly resolves your issue.

Having gone through this recently, here is how I got things working. My versions for reference...

@>node -v

v5.4.1

@>npm -v

v3.3.12

I was having issues updating to the latest TypeScript compiler. No matter what npm command I tried it would not install/update from the version I had on my system (v1.0.3.0 - from a Visual Studio install). Also, concurrent (node package concurrently) and lite-server were apparently not installed via package.json when I ran the initial install. The error I was receiving was:

npm ERR! code SELF_SIGNED_CERT_IN_CHAIN

(The Angular 2 "Getting Started" guide said to ignore the errors, so I did for a while...)


Addressing the SSL certificate issue

I eventually realized nothing was being installed due to this cert. error. I came across this SO question, and tried several of the answers, but given my work environment I ended up temporarily allowing use of HTTP instead of HTTPS, like so...

WARNING: do this at your own risk, and consider setting this back to true immediately afterwards, if you use this

npm set strict-ssl false

But if it works for you I would recommend using known registrars via...

npm config set ca=""


Fix the install (Edited)

Then you should run the npm install, or npm update if you already have, in the angular2-quickstart directory, after resolving the SSL certificate issue. Doing so, you will notice that much of the initial install would have failed, including the install of the other core dependencies (like angular2). I was focused on the development environment itself (typescript, lite-server, etc.) and had completely overlooked the fact that these libraries for the application itself were never installed.


Leaving this for reference...

If you want to explicitly install/update just those packages listed under devDependency section of package.json, you can run...

npm install -g concurrently typescript lite-sever

Thanks to this SO answer for helping me realize the package for the concurrent program is called concurrently.


Latest TypeScript complier (Edited)

I had originally mentioned the package.json referencing TypesSript v1.7.3, but it references ^1.7.3, or ">= 1.7.3", so it doesn't need to change to handle the latest version (v1.7.5 at the time of writing this).