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