The MEAN stack on Ubuntu 14.04 suddenly stopped working

Well, it stinks, here's the scoop:

I help a friend work on a website project using the MEAN stack (mongodb, express, angular and nodejs), I am running Ubuntu 14.04. I'm pretty good at Linux, and I'm an experienced web developer, but most of my experience is with the LAMP stack. I have so far fine-tuned this MEAN project until this evening. My friend started developing again this evening, and I helped them upgrade their node env on Mac (they basically do HTML / CSS with an interface, and I do a full stack) by running an npm update, and the project works fine on their comp. Assuming that I could just as easily update the node environment to be more accurate, I tried the same thing:

I tried to update the node and npm environment, because several months have passed since I did this (I know that this is bad, I messed up, I admit), I think I used Node. js v 0.3.2.something, did not think to check version numbers before this chaos ensued. But now I get crazy sets of random errors, unsatisfied dependencies, I cannot resolve unsatisfied dependencies using npm install to extract them, and I cannot fall asleep to start the dev server, I tried to remove node and npm and reinstall (nodejs are now running 0.10.25), launched apt-get update, apt-get install nodejs, apt-get install nodejs-dev, npm update, npm installation, etc., but to no avail.

I'm not stuck or disappointed, please help! Here is a selection of some errors / missing dependencies that I get:

module.js:340 throw err; ^ Error: Cannot find module './helpers' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) npm ERR! weird error 8 npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian npm ERR! not ok code 0 

and when I try to run sudo grunt, I get the following:

 Loading "jshint.js" tasks...ERROR >> Error: Cannot find module './name-stack.js' Loading "grunt-karma.js" tasks...ERROR >> Error: Cannot find module 'depd' Warning: Task "jshint" not found. Used --force, continuing. Running "concurrent:default" (concurrent) task Loading "jshint.js" tasks...ERROR >> Error: Cannot find module './name-stack.js' Loading "jshint.js" tasks...ERROR >> Error: Cannot find module './name-stack.js' Loading "grunt-karma.js" tasks...ERROR Loading "grunt-karma.js" tasks...ERROR >> Error: Cannot find module 'depd' >> Error: Cannot find module 'depd' [Error: /home/user/Projects/detrashed/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build/Release/bson.node: invalid ELF header] js-bson: Failed to load c++ bson extension, using pure JS version [Error: /home/user/Projects/detrashed/node_modules/connect- mongo/node_modules/mongodb/node_modules/bson/build/Release/bson.node: invalid ELF header] js-bson: Failed to load c++ bson extension, using pure JS version module.js:340 throw err; ^ Error: Cannot find module './collection/batch/unordered' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/home/user/Projects/detrashed/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/collection.js:21:17) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) 

How embarrassing. Any help or insight on how to tune * ck my nodejs environment would be extremely helpful because I am going to pull my hair out. Thanks in advance!

+5
source share
1 answer

So, firstly, I'm sorry that you got into this mess. Part of the reason is an error in npm update - update does not apply to semantic version control, but, unfortunately, it has not yet been fixed and continues to bite people. As a result, no one should run npm update and especially never npm update -g .

In addition, the official Debian / Ubuntu packages are slightly behind current releases, and there are some unpleasant race conditions in the npm install in node that you get from Debian. Fortunately, there are packages provided by NodeSource < https://github.com/nodesource/distributions#usage-instructions >

sudo apt-get --purge remove nodejs nodejs-legacy curl -sL https://deb.nodesource.com/setup | sudo bash - sudo apt-get install -y nodejs nodejs-legacy node -v

This should help you get the latest node , 0.10.35.

Then update npm

sudo npm install -g npm@latest npm -v

This should help you get the latest npm , 2.1.17 (or later).

Now to restore your project. First, I blew out node_modules and ran npm install . If you get any errors, send the full npm-debug.log file as gist https://gist.github.com and add the link here.

You may need to reinstall the bower and grunt-cli global packages to have them in your PATH:

sudo npm i -g bower grunt-cli

One note about npm is that almost all packages will not be installed globally; just install the package globally if you want it on the PATH command line.

+5
source

Source: https://habr.com/ru/post/1210097/


All Articles