How to build npm package from source - node.js

I'm new to npm/node and I'm trying to build this repository:
https://github.com/react-component/slider
After clone and run npm install, I get this error:
/Users/rodrigora/Projects/slider/node_modules/rc-server/lib/index.js:39
app.get('/tests/runner.html', function* () {
^
SyntaxError: Unexpected token *
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/rodrigora/Projects/slider/node_modules/rc-server/bin/start.js:3:11)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
I've reinstalled node/npm, deleted node_modules folder but nothing worked.
$ node -v
v0.12.0
$ npm -v
3.5.2
I don't have a clue how to fix it. Any help?

Related

npm will not respond at all

no matter what npm package I have, or try and install I keep getting this weird syntax error.
Users/BenNolan/.node/lib/node_modules/npm/lib/cli.js:66
module.exports = async process => {
^^^^^^^
SyntaxError: Unexpected identifier
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/BenNolan/.node/lib/node_modules/npm/bin/npm-cli.js:2:1)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
I have tried updating nvm, npm and node no matter what I try I am still getting the syntax error halfway through the install.

Firebase init throwing "Use of const in strict mode" error

I installed firebase tools using
sudo npm install -g firebase-tools
and everything seemed to install fine. I already had npm and node.js installed and these are the versions:
npm: 2.11.3
node: v0.12.7
But when I try running
firebase init
from my project file, I get this error
/usr/local/lib/node_modules/firebase-tools/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js:5
const Hoek = require('hoek');
^^^^^
SyntaxError: Use of const in strict mode.
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/lib/node_modules/firebase-tools/node_modules/request/node_modules/hawk/lib/index.js:5:33)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
How can I fix this error?
This error is due to Node.js version, you need to update to version 8 or higher.

SyntaxError: Unexpected strict mode reserved word

We have two build agents (Ubuntu 12.04), both have NodeJS 5 and Gulp 3.9 installed:
$ nodejs -v
v5.11.1
$ npm list | grep gulp
├─┬ gulp#3.9.1
But during gulp build - one agent works successfully, and other - return an error:
$ gulp build
/var/lib/go-agent/pipelines/Worker/gulpfile.js:3
let requireDir = require('require-dir');
^^^
SyntaxError: Unexpected strict mode reserved word
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/lib/node_modules/gulp/bin/gulp:19:19)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
What could be wrong here?

NodeJS Error: Module version mismatch. Expected 48, got 46

After I upgraded NodeJS and NPM to 6.2.0 and 3.9.3, when I run hexo d -g command to update my blog, I get the following error:
Error: Module version mismatch. Expected 48, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:568:18)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
{ Error: Cannot find module './build/default/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32) code: 'MODULE_NOT_FOUND' }
{ Error: Cannot find module './build/Debug/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32) code: 'MODULE_NOT_FOUND' }
(node) v8::ObjectTemplate::Set() with non-primitive values is deprecated
(node) and will stop working in the next major release.
I thought maybe Node.js is upgraded and node_modules should be reinstalled.
I tried rm -rf node_modules && npm install, but it doesn't work. I also tried sudo npm i -g npm then npm install hexo --no-optional --save, which doesn't work neither.
Any advice would be most appreciated.
Actually, after upgrading node, your installed packages kept compiled against the older version, and they need to be rebuilt. No need to delete node_modules, or running npm update.
Just run:
npm rebuild
Hexo doesn't seem to work with lastest version of node which is 6.2.0. You should use node-v4.4.5 (LTS) for a while, which is recommended version for most users.
It looks like hexo is a globally installed package, but you only reinstalled it locally. Try to reinstall it globally:
npm install hexo -g
Maybe your Global installation files has not been update, please try to update your hexo-cli with command below:
sudo npm install -g hexo-cli
which solved my problem.

Error: Cannot find module './is-buffer'

I haven't found any posts that have an answer for this one. It appears to be a sourcing issue, but no matter what I try I can't seem to source it properly. I get the following error when trying to launch my application.
is-buffer is installed. I see it in my node-modules directory.
C:\MY-APP\dataService>node dataAPI.js
module.js:338
throw err;
^
Error: Cannot find module './is-buffer'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\MY-APP\node_modules\socket.io\node_modules\so
ket.io-adapter\node_modules\socket.io-parser\index.js:11:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
I tried setting this in my binary file as well as my package.json. I'm able to change it in my binary file, but no matter what I'm not able to find the correct src dir.
I also tried npm install is-buffer -g to no avail. Any advice?
Unexpected token ILLEGAL
I was able to update the source to
var isBuf = require('C:\VF_PDO_APP\node_modules\is-buffer');
So now it seems to be going to the right place I think. Now however, I'm getting Unexpected token ILLEGAL.
C:\MY-APP\dataService>node dataAPI.js
C:\MY-APP\node_modules\socket.io\node_modules\socket.io-adapter\node_modules\socket.io-parser\binary.js:10
socket.io\node_modules\socket.io-adapter\node_modules\socket.io-parser
^^^
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\MY-APP\node_modules\socket.io\node_modules\soc
ket.io-adapter\node_modules\socket.io-parser\index.js:10:14)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
You first must install all your project dependencies, do it on the root folder of your project:
npm install
For your problem with socket.io try to:
npm install socket.io --save
For the bson problem:
npm install bson --save
(for this one probably you will need to install python and c++)

Resources