felixrieseberg / windows-build-tools

:package: Install C++ Build Tools for Windows using npm
MIT License
3.4k stars 237 forks source link

npm install --global --production windows-build-tools breaks intermediately #143

Closed Aamir010 closed 6 years ago

Aamir010 commented 6 years ago

OS Version:- Windows Server 2012 R2 NPM Version :- 5.6.0 Node Version:- v8.11.4

Logs:-

windows-build-tools@4.0.0 postinstall C:\Users\Administrator\AppData\Roaming\npm\node_modules\windows-build-tools node ./dist/index.js module.js:549 throw err;

^

Error: Cannot find module 'chalk' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (C:\Users\Administrator\AppData\Roaming\npm\node_modules\windows-build-tools\dist\start.js:3:17) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! windows-build-tools@4.0.0 postinstall: node ./dist/index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the windows-build-tools@4.0.0 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache_logs\2018-09-14T04_53_30_151Z-debug.log

And this won't happen every time. Sometime it goes well and build tool install successfully.

felixrieseberg commented 6 years ago

Are you able to verify that npm actually didn't install chalk? Chalk is a dependency and should always be available - if it isn't, it appears that npm was unable to actually install the module properly... 🤔

Aamir010 commented 6 years ago

This is what I have found on package.json on "windows-build-tools"

devDependencies": {
    "@types/chalk": "^2.2.0",
    "@types/fs-extra": "^5.0.4",
    "@types/jest": "^23.3.1",
    "@types/node": "^10.9.4",
    "jest": "^23.5.0",
    "ts-jest": "^22.4.6",
    "tslint": "^5.11.0",
    "tslint-microsoft-contrib": "^5.2.1",
    "typescript": "^3.0.3"
  }
jacobq commented 6 years ago

@Aamir010 package.json just tells npm (or yarn) what it should install (and as the previous comment shows, you'll see chalk in the dependencies section). See package.json dependencies and devDependencies docs for more info. The installed modules are placed inside node_modules, so you can look inside there to see what's installed. The problem you are seeing is very likely caused by intermittent npm problems (perhaps caused by network conditions) and not by anything in windows-build-tools.

jacobq commented 6 years ago

You may also want to consider upgrading to the latest npm (6.4.1 at the time of writing), which fixes a number of problems similar to what you experienced. See https://github.com/npm/cli#windows-install-or-upgrade

Aamir010 commented 6 years ago

@jacobq Thanks let me give it a try by upgrading npm. Do you think is there related to OS version as such ?

jacobq commented 6 years ago

@Aamir010 I'm not sure I understand your question. Refer to the link above for information about how to upgrade npm. Personally, I use nvm-windows to manage NodeJS installations on Windows so usually just upgrade NodeJS to get the latest npm rather than upgrading it in place.