Add support for global npm devDependencies
OS?
Win 10
Versions.
angular-cli: 1.0.0-beta.26 node: 7.4.0 os: win32 x64 @angular/common: 2.4.5 @angular/compiler: 2.4.5 @angular/core: 2.4.5 @angular/forms: 2.4.5 @angular/http: 2.4.5 @angular/platform-browser: 2.4.5 @angular/platform-browser-dynamic: 2.4.5 @angular/router: 3.4.5 @angular/compiler-cli: 2.4.5
Repro steps.
Create a new project, then try paring down some of the devDependencies in favor of global ones - eg for now, I'd be happy to use global karma and protractor dependencies, in order to pare down the duplicated file size and clean build time. Ideally I'd like to be able to use a global angular-cli, since it pulls down a huge dependency tree, too.
ng new app1
creates these default devDependencies in package.json:
"devDependencies": {
"@angular/compiler-cli": "^2.3.1",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.26",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "~4.0.13",
"ts-node": "1.2.1",
"tslint": "^4.3.0",
"typescript": "~2.0.3"
}
change the devDependencies section to:
"devDependencies": {
"@angular/compiler-cli": "^2.3.1",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.26",
"codelyzer": "~2.0.0-beta.1"
}
then:
# Install global dependencies
npm install -g ts-node, tslint, typescript
npm install -g jasmine-core, jasmine-spec-reporter, karma, karma-chrome-launcher, karma-cli, karma-jasmine, karma-remap-istanbul
npm install -g protractor
rm -r node_modules
npm install
ng test
The log given by the failure.
D:\src\ng\app1 [master +1 ~0 -0 | +0 ~2 -0]> ng test
Cannot find module 'D:\src\ng\app1\node_modules\karma\package.json'
Error: Cannot find module 'D:\src\ng\app1\node_modules\karma\package.json'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at requireDependency (D:\src\ng\app1\node_modules\angular-cli\tasks\test.js:6:23)
at D:\src\ng\app1\node_modules\angular-cli\tasks\test.js:16:25
at Class.run (D:\src\ng\app1\node_modules\angular-cli\tasks\test.js:15:16)
at Class.run (D:\src\ng\app1\node_modules\angular-cli\commands\test.js:30:25)
at Class.
Similarly ng build and other common commands won't work, almost surely b/c the global dev tools use case isn't supported.
I find this use case to be important, b/c time to install + build projects impacts daily developer productivity in a big way.
Hello. Sounds like Windows 10 being Windows 10... :-) Question? What is your D:\ drive? A USB drive? Google drive? Network drive? Had some issues in the past trying do save angular projects in another drive other than C:. Let us know. Cheers!
No, this isn't a windows 10 issue. D: is just my work drive, another local solid state drive, same as C:. The drive letter is irrelevant for this issue.
What I'm asking for is support for using more of the angular-cli stack in the global npm directory, particularly dependencies that are not so sensitive to angular versions. Right now, ng new app1 installs ~26,000 files and ~3,600 directories via NPM in ./node_modules - this is per project. We have ~10 different production UI projects, and ~10 more prototype UI projects. I could imagine other teams have many more. I'd like to have the possibility of using global installs of protractor, karma, and ideally typescript and angular-cli, to reduce this set and dramatically speed up build times.
The versions of protractor, karma, tsc, and angular-cli probably won't change much across a set of internal projects - so why not use global versions?
If this were possible, based on a quick test we could get a new app to be ~5,000 files and ~200 directories in ./node_modules. I understand that npm and many package authors tend to prefer everything being local, but we've made this setup work (global typescript, protractor, karma) for our angular 1.x builds. It was worth the effort for us purely to speedup the startup + build time for developers and our CI servers.
That isn't much of a CLI request, as it is a NPM question. You can use npm link to get all those from a central location.
As a default though, it's highly ill-advised to give up local deps in favor of globals.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.