angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

node-sass problem when ng new on environment without githubaccess

Open SlingingCode opened this issue 9 years ago • 7 comments

Versions

Output from: `ng --version`.
Angular CLI: 1.5.4
Node: 8.9.1
OS: win32 ia32
Angular: 5.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.4
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.21
@angular-devkit/schematics: 0.0.37
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.4
@schematics/angular: 0.1.7
typescript: 2.4.2
webpack: 3.8.1

npm -v
5.5.1

Windows 8

Repro steps

  • Step 1 pointed to proget npm config set registry pointingToOurProget

  • Step 2 installed cli npm install @angular/cli

  • Step 3 ng new testname -st -sg --minimal (flags unimportant)

  • Step 4 npm install (in folder testname)

Observed behavior

PS C:\testasig\sasstest28> npm install

> [email protected] install C:\testasig\sasstest28\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.7.2/win32-ia32-57_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.7.2/win32-ia32-57_binding.node":

connect ETIMEDOUT 192.30.253.112:443

Timed out whilst downloading the prebuilt binary

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g.

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> [email protected] postinstall C:\testasig\sasstest28\node_modules\node-sass
> node scripts/build.js

Building: C:\Program Files (x86)\nodejs\node.exe C:\testasig\sasstest28\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files (x86)\\nodejs\\node.exe',
gyp verb cli   'C:\\testasig\\sasstest28\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | win32 | ia32
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\testasig\sasstest28\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\testasig\sasstest28\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\testasig\sasstest28\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\testasig\sasstest28\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\testasig\sasstest28\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\testasig\sasstest28\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed   stack: 'Error: not found: python2\n    at getNotFoundError (C:\\testasig\\sasstest28\\node_modules\\which\\which.js:13:12)\n    at F (C:\\testasig\\sasstest28\\node_modules\\which\\which.js:68:19)\n    at E (C:\\testasig\\sasstest28\\node_modules\\which\\which.js:80:29)\n    at C:\\testasig\\sasstest28\\node_modules\\which\\which.js:89:16\n    at C:\\testasig\\sasstest28\\node_modules\\isexe\\index.js:42:5\n    at C:\\testasig\\sasstest28\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:152:21)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (C:\testasig\sasstest28\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\testasig\sasstest28\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\testasig\sasstest28\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed  python { Error: not found: python
gyp verb `which` failed     at getNotFoundError (C:\testasig\sasstest28\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\testasig\sasstest28\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\testasig\sasstest28\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\testasig\sasstest28\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed   stack: 'Error: not found: python\n    at getNotFoundError (C:\\testasig\\sasstest28\\node_modules\\which\\which.js:13:12)\n    at F (C:\\testasig\\sasstest28\\node_modules\\which\\which.js:68:19)\n    at E (C:\\testasig\\sasstest28\\node_modules\\which\\which.js:80:29)\n    at C:\\testasig\\sasstest28\\node_modules\\which\\which.js:89:16\n    at C:\\testasig\\sasstest28\\node_modules\\isexe\\index.js:42:5\n    at C:\\testasig\\sasstest28\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:152:21)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp verb check python version `C:\Python27\python.exe -c "import platform; print(platform.python_version());"` returned: "2.7.14\r\n"
gyp verb get node dir no --target version specified, falling back to host node version: 8.9.1
gyp verb command install [ '8.9.1' ]
gyp verb install input version string "8.9.1"
gyp verb install installing version: 8.9.1
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.9.1
gyp verb ensuring nodedir is created C:\Users\sjomar02\.node-gyp\8.9.1
gyp verb created nodedir C:\Users\sjomar02\.node-gyp\8.9.1
gyp http GET https://nodejs.org/download/release/v8.9.1/node-v8.9.1-headers.tar.gz
gyp WARN install got an error, rolling back install
gyp verb command remove [ '8.9.1' ]
gyp verb remove using node-gyp dir: C:\Users\sjomar02\.node-gyp
gyp verb remove removing target version: 8.9.1
gyp verb remove removing development files for version: 8.9.1
gyp ERR! configure error
gyp ERR! stack Error: connect ETIMEDOUT 104.20.23.46:443
gyp ERR! stack     at Object._errnoException (util.js:1024:11)
gyp ERR! stack     at _exceptionWithHostPort (util.js:1046:20)
gyp ERR! stack     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\testasig\\sasstest28\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\testasig\sasstest28\node_modules\node-sass
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] postinstall: `node scripts/build.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

added 45 packages in 58.53s
PS C:\testasig\sasstest28>

Desired behavior

What would like to see implemented?

What is the usecase?

Environment where github access is denied.
Have pointed registry to proget, and all packages seams to be loaded ok through proget, except for node-sass that is loaded by Angular CLI as an optional dependency.
It tries to hit github to get the package (even if we specify style=css) when we do ng new. 


What did you expect to see?
Not hitting github (hitting proget that we pointed to with npm config registry?)
I did not even expect an optional dependency be downloaded at all if not used?


### Mention any other details that might be useful (optional)

SlingingCode avatar Nov 28 '17 14:11 SlingingCode

The node-sass dependency is optional but not because projects can not be using it. It's optional because installing it can fail, like in your case. We don't have fractional CLI packages supporting only some functionality, all support is included in the install.

So the behaviour you're seeing is expected. In your environment node-sass cannot be downloaded so it's ignored and install still finishes successfully. You can tell npm to not install optional packages by using the --no-optional flag though.

Regarding the URL that node-sass uses to download the binary, you can try setting the HTTP_PROXY like the error message says, or try using the binary config parameters in the node-sass repo: https://github.com/sass/node-sass#binary-configuration-parameters

filipesilva avatar Nov 30 '17 10:11 filipesilva

Still gives me the exact same error

dimitri320 avatar Dec 27 '17 12:12 dimitri320

@dimitri320 I do not know if this will help you, but to get rid of my problems I had to take a ride to my clients office (I was on VPN) and made an npm install there. Suddenly all errors were gone. I then added the node_sass package folder to be included in source control, so my team can work through VPN connection.

SlingingCode avatar Jan 01 '18 22:01 SlingingCode

@SlingingCode : This was exactly my problem. The binary was being blocked by my office network.

roymj88 avatar Jan 30 '18 09:01 roymj88

I have faced and fixed this issue relates node-sass and python error.Try installing latest angular cli command with the steps below

Set the system variable path as well: C:\Users\windowsusername\AppData\Roaming\npm

C:\Users\windowsusername\AppData\Roaming\npm\node_modules@angular\cli\bin;

C:\Program Files\nodejs;

Then start using angular cli command prompt using: angular client project folder path>npm install -g @angular/cli@latest

angular client project folder path>npm install -g node-gyp

SatishMHiremath avatar Feb 17 '18 22:02 SatishMHiremath

I got same issue and have tried using the --no-optional.

But I got error when run "ng build". I assume it because I use sass.

So I uninstall Angular CLI and install node-gyp and windows-build-tools globally.

npm install -g node-gyp npm install –g –production windows-build-tools

Then re-install Angular CLI . It works perfectly.

bluehenry avatar Apr 06 '18 07:04 bluehenry

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.