jspm install can't download packages from npm

2019-08-09 04:51发布

问题:

I am trying to run simple angular 2 unit test application. I have cloned below git and following steps given in readme file.

https://github.com/matthewharwood/Hit-the-gym

I have setup proxy setting for npm and disabled strict-ssl setting for git. I have also exported environment variable for http_proxy and https_proxy.

When I run below command

npm install

it throws error for "jspm install" command as below:

    C:\angularjs20\unit-test1\Hit-the-gym>npm install
    npm WARN package.json @ No repository field.
    npm WARN optional dep failed, continuing fsevents@0.3.8
    |
    > phantomjs@1.9.18 install C:\angularjs20\unit-test1\Hit-the-gym\node_modules\p
    antomjs
    > node install.js

    Download already available at C:\Users\bchavan\AppData\Local\Temp\phantomjs\pha
    tomjs-1.9.8-windows.zip
    Extracting zip contents
    Removing C:\angularjs20\unit-test1\Hit-the-gym\node_modules\phantomjs\lib\phant
    m
    Copying extracted folder C:\Users\bchavan\AppData\Local\Temp\phantomjs\phantomj
    -1.9.8-windows.zip-extract-1440415812246\phantomjs-1.9.8-windows -> C:\angularj
    20\unit-test1\Hit-the-gym\node_modules\phantomjs\lib\phantom
    Writing location.js file
    Done. Phantomjs binary available at C:\angularjs20\unit-test1\Hit-the-gym\node_
    odules\phantomjs\lib\phantom\phantomjs.exe
    -
    > ws@0.4.32 install C:\angularjs20\unit-test1\Hit-the-gym\node_modules\karma\no
    e_modules\socket.io\node_modules\socket.io-client\node_modules\ws
    > (node-gyp rebuild 2> builderror.log) || (exit 0)


    C:\angularjs20\unit-test1\Hit-the-gym\node_modules\karma\node_modules\socket.io
    node_modules\socket.io-client\node_modules\ws>if not defined npm_config_node_gy
     (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_m
    dules\node-gyp\bin\node-gyp.js" rebuild )  else (rebuild)
    -
    > @ postinstall C:\angularjs20\unit-test1\Hit-the-gym
    > jspm install

         Looking up npm:jquery

    warn Error on lookup for npm:jquery, retrying (1).
         Error: unable to verify the first certificate
             at Error (native)
             at TLSSocket.<anonymous> (_tls_wrap.js:929:36)
             at TLSSocket.emit (events.js:104:17)
             at TLSSocket._finishInit (_tls_wrap.js:460:8)

    warn Error on lookup for npm:jquery, retrying (2).
         Error: unable to verify the first certificate
             at Error (native)
             at TLSSocket.<anonymous> (_tls_wrap.js:929:36)
             at TLSSocket.emit (events.js:104:17)
             at TLSSocket._finishInit (_tls_wrap.js:460:8)

    warn Error on lookup for npm:jquery, retrying (3).
         Error: unable to verify the first certificate
             at Error (native)
             at TLSSocket.<anonymous> (_tls_wrap.js:929:36)
             at TLSSocket.emit (events.js:104:17)
             at TLSSocket._finishInit (_tls_wrap.js:460:8)

    warn Error on lookup for npm:jquery
         Error: unable to verify the first certificate
             at Error (native)
             at TLSSocket.<anonymous> (_tls_wrap.js:929:36)
             at TLSSocket.emit (events.js:104:17)
             at TLSSocket._finishInit (_tls_wrap.js:460:8)

    err  Error looking up npm:jquery.

    warn Installation changes not saved.

    npm ERR! Windows_NT 6.1.7601
    npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodej
    \\node_modules\\npm\\bin\\npm-cli.js" "install"
    npm ERR! node v0.12.2
    npm ERR! npm  v2.7.4
    npm ERR! code ELIFECYCLE
    npm ERR! @ postinstall: `jspm install`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the @ postinstall script 'jspm install'.
    npm ERR! This is most likely a problem with the  package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     jspm install
    npm ERR! You can get their info via:
    npm ERR!     npm owner ls
    npm ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request:
    npm ERR!     C:\angularjs20\unit-test1\Hit-the-gym\npm-debug.log

Below is the package.json file content:

        {
     "jspm": {
       "directories": {},
       "dependencies": {
         "jquery": "npm:jquery@^2.1.4"
       },
       "devDependencies": {
         "traceur": "github:jmcriffey/bower-traceur@0.0.89",
         "traceur-runtime": "github:jmcriffey/bower-traceur-runtime@0.0.89"
       }
     },
     "scripts": {
       "postinstall": "jspm install",
       "start": "live-server --open=client/index.html --port=9090 ./"
     },
     "devDependencies": {
       "jasmine-core": "^2.3.4",
       "jspm": "^0.15.6",
       "karma": "^0.12.35",
       "karma-chrome-launcher": "^0.1.12",
       "karma-coverage": "^0.3.1",
       "karma-jasmine": "^0.3.5",
       "karma-jspm": "^1.1.5",
       "karma-phantomjs-launcher": "^0.2.0",
       "phantomjs": "^1.9.17"
     }

Could anybody please help me to solve this issue?

Any help very much appreciated!

回答1:

I had problem with npm too, but I'm not sure if it was the same problem. Sorry if not.

I have fixed it by adding the line "strict-ssl=false" to the file: C:\Users{username}\npmrc (create if not exist)