1

According to this post and this post, I can install packages by using command

npm install --prefix <path/to/prefix_folder> -g

--prefix is for specifying the location and -g is tell the npm to globally install.

However, neither using -g nor doesn't, it entirely copies my project to the prefix folder and create an npm_modules in the root of the cloned project while I execute the command!! Without --prefix the command can install packages correctly.

the package.json as bellow:

{
  "name": "Javims-cms",
  "version": "1.0.0",
  "scripts": {
    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",    
    "tsc": "tsc -p D:/localhost.server.com/projects/javims/mysite/cms",
    "tsc:w": "tsc -w -p D:/localhost.server.com/projects/javims/mysite/cms",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install" 
  },
  "license": "ISC",
  "dependencies": {
    "angular2": "2.0.0-beta.7",
    "systemjs": "0.19.22",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "zone.js": "0.5.15",
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.1.0",
    "typescript": "^1.8.2",
    "typings":"^0.6.8"
  }
}

Updates:

//the file structure of my project:  
myproject(project root)
    -access
    -package.json
    -typings.json
    -tsconfig.json

//the file structure after I run npm install --prefix ./access [-g] from project root
myproject(project root)
      -access
         -npm_modules
              -myproject(project root)
              -access
                 -npm_modules
                     - [packages]
              -package.json
              -typings.json
              -tsconfig.json
      -package.json
      -typings.json
      -tsconfig.json

//what I am expecting
myproject(project root)
   -access
      -npm_modules
          -(packages)
   -package.json
   -typings.json
   -tsconfig.json
Community
  • 1
  • 1
panda
  • 1,344
  • 3
  • 14
  • 35
  • are you trying to install a specific package globally . or run an installation or your dependencies ? – eran otzap Mar 05 '16 at 19:35
  • @eranotzap I am trying to install packages via a package.json which sits in my project root, and I ran the installation from my project root – panda Mar 07 '16 at 03:26
  • A) why -g ? do you wan't all your dependency to be installed globally ? kinda weird .. B) What exactly gets copied to the "prefix_folder" as you call it . You said all your project gets copied when infect you expect only your dependencies (packages) to be in that folder. please post a screen shoot of the source directory and specify what you did not expect to be there. – eran otzap Mar 07 '16 at 04:50
  • @eranotzap I am not sure why a -g because I am so new in npm, and after read those two post above, I added a -g, however, the problem shows neither adding a -g nor not. I added an example for copying whole project example. – panda Mar 07 '16 at 06:43
  • so you'r doing a --prefix into the same folder ? post the actual command + path – eran otzap Mar 07 '16 at 07:32
  • @eranotzap I am using npm install --prefix ./access -g or npm install --prefix access -g in my project. I want to put npm_modules into the access folder – panda Mar 07 '16 at 07:35
  • I get the same results - mu entire project root gets copied into the --prefix directory – ed4becky Oct 09 '16 at 17:46
  • There is a related & open issue on npm about this: https://github.com/npm/npm/issues/11007 – kuzyn Mar 23 '17 at 14:30

0 Answers0