How can I make this npm project works? - node.js

I'm trying to make working a tool that I found on Github and I'm not able to get in touch with the creator of this.
I've this output:
const express = require('express'),
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
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 Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
npm ERR! Windows_NT 6.2.9200
npm ERR! argv "D:\\Program Files (x86)\\nodejs\\0.10.29\\node.exe" "D:\\Program Files (x86)\\npm\\3.9.5\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v0.10.29
npm ERR! npm v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! PROJECT-NAME#0.0.0 start: `node ./app.js`
npm ERR! Exit status 8
How can I do (I'm using windows)?
Thank you so much!

To enable some of the ECMAScript 2015 features (including const) in Node.js 0.10 start your node program with a harmony flag, otherwise you will get a syntax error. For example:
node --harmony app.js

Related

There is a problem when running a node application on ubuntu 18.04

I am trying to run a node site on an azure VM but I get this error when running > SkyCrypt#1.0.0 start
> node init && node index
internal/modules/cjs/loader.js:1109
throw err;
^
SyntaxError: /home/nim1com/SkyCrypt/credentials.json: Unexpected token v in JSON at position 216
at parse (<anonymous>)
at Object.Module._extensions..json (internal/modules/cjs/loader.js:1106:22)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/nim1com/SkyCrypt/init.js:15:21)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! SkyCrypt#1.0.0 start: `node init && node index`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the SkyCrypt#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/nim1com/.npm/_logs/2021-01-19T09_41_40_472Z-debug.log```
What would be the answer to this problem? I have tried deleting package-lock.json and node_modules
credentials.json
{
"hypixel_api_key": "26ed366f-80ed-4b49-b912-ef46292c6225",
"recaptcha_site_key": "",
"recaptcha_secret_key": "",
"dbUrl": "mongodb+srv://dbStats:*********#cluster0.4kwsp.mongodb.net/test?retryWrites=true&w=majority",
"dbName": vmstats",
"session_secret": "36e47c144b9b9b3e0b9c8bf24c6ac2860c0f76a55b74dcea4007bf355af76789"
}
It seems your /home/nim1com/SkyCrypt/credentials.json file need to be corrected ...
read the error its complaining about the v in "dbName": vmstats", because is not valid json – Lawrence Cherone

while installing cosmos gui "npm start" throws error

[cosmos-gui#cosmos-instance cosmos-gui]$ npm start
cosmos-gui#1.0.0-next start /home/cosmos-gui/fiware-cosmos/cosmos-gui
> node ./src/cosmos_gui.js
/home/cosmos-gui/fiware-cosmos/cosmos-gui/node_modules/express/lib/express.js:110
throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.');
^
Error: Most middleware (like logger) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.
at Function.get (/home/cosmos-gui/fiware-cosmos/cosmos-gui/node_modules/express/lib/express.js:110:13)
at Object. (/home/cosmos-gui/fiware-cosmos/cosmos-gui/src/cosmos_gui.js:66:17)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cosmos-gui#1.0.0-next start: node ./src/cosmos_gui.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cosmos-gui#1.0.0-next start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/cosmos-gui/.npm/_logs/2019-02-13T09_22_21_224Z-debug.log
Any solution for this?

NPM showing error message after adding the Prop-Types in react project

This is the error message after I finished installation of Prop-Types Validation in my create-react-app
> burgerapp#0.1.0 start C:\Users\ajeet\Desktop\burgerapp
> node scripts/start.js
module.js:540
throw err;
^
Error: Cannot find module 'webpack'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\ajeet\Desktop\burgerapp\scripts\start.js:19:17)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! burgerapp#0.1.0 start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the burgerapp#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ajeet\AppData\Roaming\npm-cache\_logs\2018-02-04T23_43_08_160Z-debug.log
Please help me to find solution. Thank you for your help.
this just sometimes happens with npm when adding packages, especially with create-react-app projects. Delete node_modules and run npm install again, that should fix it.
You can install webpack by using command 'npm install webpack --dev'.

Nodejs: npm throwing error when using monk

I'm building a NodeJS app using ExpressJS framework.
I'm trying to use monk to connect to MongoDB
var monk = require('monk');
var db = monk('localhost:3000/nodeauth');
When I do npm start , I'm getting the following error:
npm start
> jsblog#0.0.0 start /home/bytegeek/Codes/Expressprojects/jsblog
> node ./bin/www
/home/bytegeek/Codes/Expressprojects/jsblog/node_modules/mongoskin/lib/utils.js:33
var skinClassName = 'Skin' + NativeClass.name;
^
TypeError: Cannot read property 'name' of undefined
at makeSkinClass (/home/bytegeek/Codes/Expressprojects/jsblog/node_modules/mongoskin/lib/utils.js:33:43)
at Object.<anonymous> (/home/bytegeek/Codes/Expressprojects/jsblog/node_modules/mongoskin/lib/grid.js:6:35)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/home/bytegeek/Codes/Expressprojects/jsblog/node_modules/mongoskin/lib/db.js:22:16)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/home/bytegeek/Codes/Expressprojects/jsblog/node_modules/mongoskin/lib/mongo_client.js:5:14)
npm ERR! Linux 4.2.0-34-generic
npm ERR! argv "/opt/node-v5.7.1-linux-x64/bin/node" "/opt/node-v5.7.1-linux-x64/bin/npm" "start"
npm ERR! node v5.7.1
npm ERR! npm v3.6.0
npm ERR! code ELIFECYCLE
npm ERR! jsblog#0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jsblog#0.0.0 start script 'node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the jsblog package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs jsblog
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls jsblog
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/bytegeek/Codes/Expressprojects/jsblog/npm-debug.log
I already have a MongoDB database nodeauth and also have some contents in it. mongod service is also running.
P.S: If I remove the above two lines of codes and do npm start , there is no error and I'm able to see the express welcome page at localhost:3000
Check your MongoDB port where it is running. if you did not change the default port , it should be http://localhost:27017/nodeauth
I think your app is running on 3000 port. so, check the mongod port and check again.
omit he port number for monk module. try this way.
var db = require('monk')('localhost/nodeauth');

NPM: cannot find module './lib' after upgrading to Node.js 5.0 on OS X

Background
I just upgraded from Node.js v4.1.1 to v5.0.0 on my Mac. I used the node-v5.0.0.pkg installer from the node website because I don't have nvm or n installed, and I didn't install through Homebrew or MacPorts).
Problem
Now, every time I run npm I get the following error in my terminal:
Error: Cannot find module './lib'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk/index.js:1:80)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432: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)
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm"
npm ERR! node v5.0.0
npm ERR! npm v3.3.6
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './lib'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
I can't even re-install NPM through the traditional method of running npm install -g npm because the package manager itself doesn't work.
How do I get NPM working again on my Mac?
Solution:
rm -rf /usr/local/lib/node_modules/npm
Reinstall node js v5.0.0
Other notes:
Looks like other people are running in to the same problem (see issue #3606). It sounds like a fix is in the works, so this issue will probably be resolved in the next release. In the interim, the only solution is to completely purge npm from your system and reinstall.

Resources