Error when running npm-install: Could not install . Error! No version provided

14,047

Solution 1

As the error says, your package.json is missing a version field. Add one and the error should go away.

Solution 2

yes, it's looks it's treat the -g as package i don't know the exact reason why but these worked for me

  • 1: if you opened the cmd window as administrator close it and open the usual cmd(not admin)
  • 2: your window is opened before finishing nodejs setup so close it and reopen it.

Solution 3

You need a version in your package.json, as indicated here: https://www.npmjs.org/doc/files/package.json.html

The most important things in your package.json are the name and version fields. Those are actually required, and your package won't install without them. The name and version together form an identifier that is assumed to be completely unique.

Share:
14,047
Ryan McGarvey
Author by

Ryan McGarvey

Updated on June 05, 2022

Comments

  • Ryan McGarvey
    Ryan McGarvey almost 2 years

    Just got a new hard drive, installed GIT, Mongodb, node and npm, added GIT to the PATH, and tried to run npm install -g. Here's the full error message:

    npm ERR! addLocal Could not install .
    npm ERR! Error: No version provided
    npm ERR!     at needVersion (C:\Program Files\nodejs\node_modules\npm\lib\cache
    add-local.js:144:40)
    npm ERR!     at C:\Program Files\nodejs\node_modules\npm\lib\cache\add-local.js
    77:10
    npm ERR!     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-pack
    ge-json\read-json.js:51:40
    npm ERR!     at final (C:\Program Files\nodejs\node_modules\npm\node_modules\re
    d-package-json\read-json.js:349:17)
    npm ERR!     at then (C:\Program Files\nodejs\node_modules\npm\node_modules\rea
    -package-json\read-json.js:126:33)
    npm ERR!     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-pack
    ge-json\read-json.js:316:48
    npm ERR!     at evalmachine.<anonymous>:207:20
    npm ERR!     at OpenReq.Req.done (C:\Program Files\nodejs\node_modules\npm\node
    modules\graceful-fs\graceful-fs.js:141:5)
    npm ERR!     at OpenReq.done (C:\Program Files\nodejs\node_modules\npm\node_mod
    les\graceful-fs\graceful-fs.js:61:22)
    npm ERR!     at Object.oncomplete (evalmachine.<anonymous>:107:15)
    npm ERR! If you need help, you may report this *entire* log,
    npm ERR! including the npm and node versions, at:
    npm ERR!     <http://github.com/npm/npm/issues>
    
    npm ERR! System Windows_NT 6.1.7601
    npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\no
    ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g"
    npm ERR! cwd C:\Users\username\NSFCyberHealth\server
    npm ERR! node -v v0.10.32
    npm ERR! npm -v 1.4.28
    npm ERR!
    npm ERR! Additional logging details can be found in:
    npm ERR!     C:\Users\username\NSFCyberHealth\server\npm-debug.log
    npm ERR! not ok code 0
    

    I've searched for other people with this issue, but haven't been able to find any fixes. here is my package.json file:

    {
      "name": "node-authentication",
      "main": "server.js",
      "dependencies" : {
        "express" : "~3.4.4",
        "ejs" : "~0.8.5",
        "mongoose" : "~3.8.1",
        "passport" : "~0.1.17",
        "passport-local" : "~0.1.6",
        "passport-facebook" : "~1.0.2",
        "passport-twitter" : "~1.0.2",
        "passport-google-oauth" : "~0.1.5",
        "connect-flash" : "~0.1.1",
        "bcrypt-nodejs" : "latest",
        "socket.io" : "0.9.x",
        "JSV" : "4.0.x"
      }
    }
    

    Does anyone know what is causing this error?