Basicly i am trying to run the node.js script with a cmd here is what i get error on
var mysql = require('mysql'); var log4js = require('log4js'); var io = require('socket.io')(3000); var request = require('request'); var fs = require('fs'); var md5 = require('md5'); var sha256 = require('sha256'); var math = require('mathjs'); var antiSpam = require('socket-anti-spam'); var seedrandom = require('seedrandom'); var crypto = require('crypto');
here is a example of what kind of error i get (picture)
and i dont understand much out of this so i appriciate all answers!
1
.
This is a node file, to run the node file, you must have node installed
what you have done is just provided the site.js
If node is already installed then
do npm install
then node site.js
just do console.log(process.argv)
inside site.js
file, you will get
[ '/home/pk/.nvm/versions/node/v7.6.0/bin/node', '/media/pk/E/test/site.js' ]
The first index is the node command path, second is the path to your file
2
.
Error: cannot find module mysql
means you don't have the mysql module installed
do npm install mysql --save
, or if you want to install all the dependencies listed in your package.json
, then just do npm install
you can do npm install module_name --save
for the each required module
Download nodejs from https://nodejs.org/en/ . Run it with node site.js
Just create a package.json file containing the following json object:
{
"name": "my-cool-app",
"version": "1.0.0",
"description": "This is my cool app",
"author": "Me",
"license": "MIT",
"dependencies": {
"mysql":"",
"log4js":"",
"socket.io":"",
"request":"",
"fs":"",
"md5":"",
"sha256":"",
"mathjs":"",
"socket-anti-spam":"",
"seedrandom":"",
"crypto":""
}
}
Then run in the command prompt:
npm install
node site.js
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.