Problem with a npm library(webpack-dev-middleware)

nodejs

#1

Hi, i got an error when i make node server.js. This is the syntax error:

jesus@jesus-eMachines-E725:~/react_npm/my_proyects/express_test$ node buildScripts/server.js
/home/jesus/react_npm/my_proyects/express_test/node_modules/webpack-dev-middleware/index.js:7
const { getFilenameFromUrl, noop, ready, setFs } = require(’./lib/util’);
^

SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions…js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/home/jesus/react_npm/my_proyects/express_test/buildScripts/server.js:6:20)
at Module._compile (module.js:410:26)
at Object.Module._extensions…js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3

and i have a similar error when i make:
const {a, b} = “foo”;

I have ubuntu 16.04, 32-bits. What can i do to solve the problem?

Merry chritsmas.


#2

Ubuntu’s packages are often a bit on the old side, Xenial was released april '16, its packages frozen months before that, and they probably weren’t the latest even then

I suggest downloading the precompiled current version from nodejs’s website and extracting it somewhere in your home directory, add its bin directory to your PATH (add it at the front of the PATH so that it precedes the one you installed system-wide)

What you particularly should not do is dropping the files into the directories managed by your package manager, you’ll have a difficult time cleaning that up later and you might get collisions. If you want a system-wide install then I suggest compiling it yourself, setting its installation prefix to /usr/local, and using checkinstall instead of make install, but really, the previous suggestion is simpler.