Search code examples
node.jswindowsangular-cli

Node.js SurfaceBook Win10 : @angular/cli will not install


Tech details:

  • SurfaceBook/win10 up to date;
  • Node.js 8.9.4 x64
  • Using an admin account

The goal was to take an app (nothing special about the web app) and make it run on this laptop. It works fine on my other devices (win7 and Linux).

I tried to solve the problem with other answers from StackOverflow. I went through : Removing files (Appdata/roaming/npm & npm-cache); uninstall node.js, reinstall and such. Nothing works.

I have a strange message when using NPM (the win version) in cmd.exe prompt. But it does not talk much under Git bash.

C:\Users\TexMex>npm -v
'CALL "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g' n’est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
5.6.0

C:\Users\TexMex>

The Git Bash is more silent. It doesn't mean it's not going through the same problem. The "PATH" environment variableS are set properly according to other StackOverflow answers. Still... it works... Ok it's not that of a problem as long as it works.

When installing packages everything goes well until @Angular/cli. I end up with this "uglify postinstall" error every time.

    [...]
34735 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
    34736 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
    34736 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
    34736 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
    34736 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
    34737 warn optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\@angular\cli\node_modules\node-sass):
    34738 warn optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node scripts/install.js`
    34738 warn optional SKIPPING OPTIONAL DEPENDENCY: spawn C:\WINDOWS\system32\cmd.exe; ENOENT
    34739 verbose optional SKIPPING OPTIONAL DEPENDENCY:
    34739 verbose optional Failed at the [email protected] install script.
    34739 verbose optional SKIPPING OPTIONAL DEPENDENCY: This is probably not a problem with npm. There is likely additional logging output above.
    34740 verbose stack Error: [email protected] postinstall: `node lib/post_install.js`
    34740 verbose stack spawn C:\WINDOWS\system32\cmd.exe; ENOENT
    34740 verbose stack     at _errnoException (util.js:1022:11)
    34740 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    34740 verbose stack     at onErrorNT (internal/child_process.js:372:16)
    34740 verbose stack     at _combinedTickCallback (internal/process/next_tick.js:138:11)
    34740 verbose stack     at process._tickCallback (internal/process/next_tick.js:180:9)
    34741 verbose pkgid [email protected]
    34742 verbose cwd C:\Users\TexMex\Desktop\DEV\git
    34743 verbose Windows_NT 10.0.16299
    34744 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "--save-dev" "@angular/cli@latest"
    34745 verbose node v8.9.4
    34746 verbose npm  v5.6.0
    34747 error file C:\WINDOWS\system32\cmd.exe;
    34748 error path C:\WINDOWS\system32\cmd.exe;
    34749 error code ELIFECYCLE
    34750 error errno ENOENT
    34751 error syscall spawn C:\WINDOWS\system32\cmd.exe;
    34752 error [email protected] postinstall: `node lib/post_install.js`
    34752 error spawn C:\WINDOWS\system32\cmd.exe; ENOENT
    34753 error Failed at the [email protected] postinstall script.
    34753 error This is probably not a problem with npm. There is likely additional logging output above.
    34754 verbose exit [ 1, true ]

The thing is it prevents @angular/cli directory to be created and the corresponding files to be "landed" here (global install or not). the 'ng' command is not available as a result (it's embarrassing).

I did my homework tried all the StackOverflow answer i could find; and I'm out of ideas.

Maybe it's some spurts in the windows registry (some previous install of nodeJS)?? but what are the keys to remove from the registry if there is??? Is it relevant to clean the registry in that case? Is it specific to surface book ??? All this would be weird.

So the final question is : How do I make it work, 100% sure shot?

Bottle in the sea... Help.


Solution

  • I think i found the root cause of the problem.

    It seems that an online Microsoft account (which is easily activated when using W10 and SurfaceBooks) forbids software to modify some directory in the user home directory. This directory (or part of it) is somehow synchronized with the Microsoft service.

    So you cannot "mess" with it like if it was only local. Those directories appear like system protected directories when using the service. When not using it; they're just hidden like you all probably know. "AppData" and such are the ones who are synchronized.

    Also, I would recommend to use NodeJs/Angular with Docker. Especially as Angular is regularly updated since version 4.