npm install --prefix <path/to/prefix_folder> -g
--prefix
用于指定位置,-g
告诉npm全局安装。
但是,既没有使用-g
也没有使用它,它完全将我的项目复制到前缀文件夹,并在执行命令时在克隆项目的根目录中创建npm_modules
!如果没有--prefix
,该命令可以正确安装包。
package.json如下:
{
"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"
}
}
更新
//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