angular / angular-cli

CLI tool for Angular
https://cli.angular.dev
MIT License
26.78k stars 11.98k forks source link

Failed to build zopfli (was: Installation failed on Ubuntu 16.04LTS with Node 7.0.0 and npm 3.10.9) #3027

Closed koalabi closed 8 years ago

koalabi commented 8 years ago

Please provide us with the following information:

OS?

Ubuntu 16.04LTS

Versions.

ng claims to be installed but outputs undefined to 'ng --version' (node --version : 7.0.0)

Repro steps.

"ng new" fails silently: no error message but no file (nor directory) creation.

The log given by the failure.

(No log: absolutely no output, despite 'which ng' yielding '/usr/local/bin/ng' :-()

Mention any other details that might be useful.

Installation emitted several warning (deprecations) and errors when attempting to compile native extensions (maybe due to the unavoidable sudo under Ubuntu for "npm install ... -g"?). Problem is compounded by the fact that reinstalling or uninstalling/reinstalling does not seem to trigger compilation attempts again; so I'm stuck.

Output from very first installation attached below: ng-cli.install.log-1.txt


Thanks! We'll be in touch soon.

koalabi commented 8 years ago

UPDATE: short of anything better, I followed the procedure described for manual upgrades of beta (uninstall, clean cache, reinstall), while being root (sudo bash). Now, ng seems to be installed and at least partially running (will check further) but the build errors for native extensions remain (see attached file for details).

--- start log excerpt ---

node install.js

[execsync v1.0.2] Attempting to compile native extensions. [execSync v1.0.2] Native code compile failed!!

node-zopfli@2.0.1 install /usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.1-node-v51-linux-x64.tar.gz node-pre-gyp ERR! Pre-built binaries not found for node-zopfli@2.0.1 and node@7.0.0 (node-v51 ABI) (falling back to source compile with node-gyp) gyp WARN EACCES user "root" does not have permission to access the dev dir "/home/alain/.node-gyp/7.0.0" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli/.node-gyp" make: Entering directory '/usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli/build' make: *\ No rule to make target '../.node-gyp/7.0.0/include/node/common.gypi', needed by 'Makefile'. Stop. make: Leaving directory '/usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli/build' gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/angular-cli/node_modules/node-gyp/lib/build.js:276:23) gyp ERR! stack at emitTwo (events.js:106:13) gyp ERR! stack at ChildProcess.emit (events.js:191:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12) gyp ERR! System Linux 4.4.0-45-generic gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/angular-cli/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli/lib/binding/node-v51-linux-x64/zopfli.node" "--module_name=zopfli" "--module_path=/usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli/lib/binding/node-v51-linux-x64" gyp ERR! cwd /usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli gyp ERR! node -v v7.0.0 gyp ERR! node-gyp -v v3.4.0 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/angular-cli/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli/lib/binding/node-v51-linux-x64/zopfli.node --module_name=zopfli --module_path=/usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli/lib/binding/node-v51-linux-x64' (1) node-pre-gyp ERR! stack at ChildProcess. (/usr/local/lib/node_modules/angular-cli/node_modules/node-pre-gyp/lib/util/compile.js:83:29) node-pre-gyp ERR! stack at emitTwo (events.js:106:13) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:191:7) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:877:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) node-pre-gyp ERR! System Linux 4.4.0-45-generic node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/angular-cli/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd /usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli node-pre-gyp ERR! node -v v7.0.0 node-pre-gyp ERR! node-pre-gyp -v v0.6.31 node-pre-gyp ERR! not ok Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/angular-cli/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli/lib/binding/node-v51-linux-x64/zopfli.node --module_name=zopfli --module_path=/usr/local/lib/node_modules/angular-cli/node_modules/node-zopfli/lib/binding/node-v51-linux-x64' (1) ng-cli.install.log-2-OK.txt --- end log excerpt ---

filipesilva commented 8 years ago

The native extension build errors can be safely ignored. As long as npm install -g angular-cli does not exit with an error code, it should be installed correctly. Any node-gyp or node-pre-gyp errors are the result of optional installs (at least usually).

Sudo should be avoided, see here https://docs.npmjs.com/getting-started/fixing-npm-permissions. That was probably the reason for your errors from the start.

JanStureNielsen commented 8 years ago

@koalabi -- see http://stackoverflow.com/questions/39812448/angular-cli-installation-failure

koalabi commented 8 years ago

OK, noted. Thanks to both :-)

jb-ertw commented 7 years ago

(Duplicating my comment on #3214)

For those who are still wondering...

The issue in most cases is that the node-zopfil package needs to be locally compiled on most systems, and it requires C++11 compilation options.

For those of you on an Ubuntu/Debian distro, this means using a g++ compiler with a version 5.1 or later. If you wish to upgrade the default compiler, follow these steps:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5.1 g++-5.1
sudo rm /bin/usr/g++
sudo ln -s /usr/bin/g++-5 /usr/bin/g++

You will still get some compiler warnings about unused functions, but the overall NPM setup and installation should proceed without error.

angular-automatic-lock-bot[bot] commented 5 years ago

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.