Unable to run server and error displayed in command prompt - javascript

I am trying to open the web page with the code followed in github and unable to run the server facing the errors and displayed in command prompt as below:
Code link: https://github.com/mschwarzmueller/nodejs-basics-tutorial/tree/master/09-mongodb
Error:
05-express-first-app#0.0.0 start C:\Users\Atchaya\Downloads\nodejs-basics-tutorial-master\09-mongodb
node ./bin/www
module.js:471
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Atchaya\Downloads\nodejs-basics-tutorial-master\09-mongodb\app.js:1:77)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 05-express-first-app#0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 05-express-first-app#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 05-express-first-app 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 05-express-first-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls 05-express-first-app
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Atchaya\AppData\Roaming\npm-cache\_logs\2017-04-19T14_14_54_505Z-debug.log

Go you your 09-mongodb folder, then run npm install command, then run npm run start.
npm install -
This command installs a package, and any packages that it depends on.
If the package has a shrinkwrap file, the installation of dependencies
will be driven by that.
By default, npm install will install all modules listed as
dependencies in package.json.

Related

I created a project with create-react-app. on my windows pc but when is try to run npm start on the command line it shows this error.please help me

Got an error on npm start
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the raber-react#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\lectriweb\AppData\Roaming\npm-cache\_logs\2020-08-17T09_32_32_695Z-debug.log
PS C:\Users\lectriweb\Documents\raber-react> npm start
> raber-react#0.1.0 start C:\Users\lectriweb\Documents\raber-react
> react-scripts start
internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module 'emojis-list'
Require stack:
- C:\Users\lectriweb\Documents\raber-react\node_modules\loader-utils\lib\interpolateName.js
- C:\Users\lectriweb\Documents\raber-react\node_modules\loader-utils\lib\index.js
- C:\Users\lectriweb\Documents\raber-react\node_modules\html-webpack-plugin\index.js
- C:\Users\lectriweb\Documents\raber-react\node_modules\react-scripts\config\webpack.config.js
- C:\Users\lectriweb\Documents\raber-react\node_modules\react-scripts\scripts\start.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\lectriweb\Documents\raber-react\node_modules\loader-utils\lib\interpolateName.js:4:20)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\lectriweb\\Documents\\raber-react\\node_modules\\loader-utils\\lib\\interpolateName.js',
'C:\\Users\\lectriweb\\Documents\\raber-react\\node_modules\\loader-utils\\lib\\index.js',
'C:\\Users\\lectriweb\\Documents\\raber-react\\node_modules\\html-webpack-plugin\\index.js',
'C:\\Users\\lectriweb\\Documents\\raber-react\\node_modules\\react-scripts\\config\\webpack.config.js',
'C:\\Users\\lectriweb\\Documents\\raber-react\\node_modules\\react-scripts\\scripts\\start.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! raber-react#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the raber-react#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\lectriweb\AppData\Roaming\npm-cache\_logs\2020-08-17T09_50_07_067Z-debug.log
Looks like Node can't find the module called 'emojis-list'.
Open your terminal, go inside your folder and try installing all the packages with:
npm install
If it doesn't work, try installing the emojis-list itself:
npm install emojis-list --save

What else do I need to try to resolve this npm start error?

I have tried to resolve this by reading other stack overflow entries before posting, but the same error message keeps showing up.
I am trying to run a Javascript program that integrates ReactJS. It worked for a while and every time I would type "npm start" it would automatically bring up the webpage template in the browser. Now it gives me the following error(s):
jMBP:project javen$ npm start
> react-box#0.1.0 start /Users/javen/Desktop/project
> node scripts/start.js
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'react-dev-utils/prompt'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/Users/sland/Desktop/project/scripts/start.js:20:14)
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)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-box#0.1.0 start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-box#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! /Users/javen/.npm/_logs/2018-09-27T01_24_06_237Z-debug.log
I have the following installed:
node -v: v10.9.0
npm -v: 6.4.1
I have tried the following:
npm install --save-dev react-dev-utils
npm install -g npm#latest
rm -rf node_modules
npm install //this threw a lot of errors
In the package.json file, for react-dev-utils it says, "react-dev-utils": "^5.0.2" Also, I do not know if this matters, but in the process of trying fixing this, a package-lock.json file has shown up in my project folder. The "prompt" var the error is referring to is the start.js folder: var prompt = require('react-dev-utils/prompt');
I have read that downgrading to an older version of node can sometimes work. If this is the case, which version is best, and how do I do this? Any advice appreciated.
I think npm install --save-dev react-dev-utils commands generally solves the issue. If not then updating your configs to match the latest create-react-app will fix this issue.

parse-server fails to start

I have followed the commands below (https://github.com/parse-community/parse-server) to install parse server locally.
$ npm install -g parse-server mongodb-runner
$ mongodb-runner start
$ parse-server --appId myserver --masterKey myserver --databaseURI mongodb://localhost/test
the server files are downloaded and stored at ~/.npm-global/lib/node_modules/parse-server.
when i try to run the 3rd command
parse-server --appId myserver --masterKey myserver --databaseURI mongodb://localhost/test on the terminal, I get the error below
parse-server: command not found
When i try to run npm start on the terminal from the same folder, I get the error below
parse-server#2.7.4 start /home/user/.npm-global/lib/node_modules/parse-server
> node ./bin/parse-server
/home/user/.npm-global/lib/node_modules/parse-server/lib/ParseServer.js:124
const {
^
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.<anonymous> (/home/user/.npm-global/lib/node_modules/parse-server/lib/index.js:8:21)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
npm ERR! Linux 4.4.0-112-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/local/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! parse-server#2.7.4 start: `node ./bin/parse-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the parse-server#2.7.4 start script 'node ./bin/parse-server'.
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 parse-server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/parse-server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs parse-server
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls parse-server
npm ERR! There is likely additional logging output above.
how can i run it?
Another thing, I had already installed mongodb and was using it before trying to install parse-server on my laptop. did
npm install -g parse-server mongodb-runner
mongodb-runner start
install another mongo db on my laptop?
I was able to solve the problem by updating my nodejs version from 4.2.6 to 8.11.1 using the commands below
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
After that, I added parse-server path to /etc/enviroment file
sudo gedit /etc/enviroment
appended this line :~/.npm-global/bin
then I run source /etc/enviroment command
and was able to start parse-server from the terminal
parse-server --appId myserver --masterKey myserver --databaseURI mongodb://localhost/test

Unable to Render nested tags in server side Riot.JS

I'm trying to use Riotjs in server side
I have three files testcmp.js , test1.tag , test2.tag
testcmp.js
var riot = require('riot');
var test1 = require('../src/components/test/test1.tag')
var test2 = require('../src/components/test/test2.tag')
console.log(riot.render('test2',{yo2:"hello"}))
test1.tag
<test1><div>I'm in test1 {opts.yo}</div></test1>
test2.tag
<test2>
<test1 yo="sujeet"></test1>
hello, I'm in test2 {yo2}
</test2>
and when I run the testcmp.js file, I get the following error message
/home/sujeet/Desktop/labz/authblue-ui-ssr-spike/src/components/test/test2.tag:2
var riot = require('riot')
^^^^^^^^^^^^^^^
ReferenceError: Invalid left-hand side in assignment
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at loadAndCompile (/home/sujeet/Desktop/labz/authblue-ui-ssr-spike/node_modules/riot/lib/server/index.js:33:11)
at Object.require.extensions..tag (/home/sujeet/Desktop/labz/authblue-ui-ssr-spike/node_modules/riot/lib/server/index.js:55:3)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
npm ERR! Linux 4.13.0-32-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "testcmp"
npm ERR! node v6.11.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! authblue-ui-ssr-spike#1.0.0 testcmp: `node scripts/testcmp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the authblue-ui-ssr-spike#1.0.0 testcmp script 'node scripts/testcmp'.
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 authblue-ui-ssr-spike package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/testcmp
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs authblue-ui-ssr-spike
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls authblue-ui-ssr-spike
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/sujeet/Desktop/labz/authblue-ui-ssr-spike/npm-debug.log
Enclosing the text inside the test2.tag file helped me fix the issue.
Basically, something like this
<test2>
<test1 yo="sujeet"></test1>
<span>hello, I'm in test2 {yo2} </span>
</test2>

How to properly use local paths in NPM and require method in Node.js

I'm having an issue trying to clean up some code.
Here is the portion of code where I am trying to import certain files from the pageObject directory, these LOC are in all my test files:
var config = require('../../../../adminVariables');
var AdminLogin = require('../../../../pageObject/admin/login/index');
var HeaderProfile = require('../../../../pageObject/admin/login/common/headerProfile/index');
var AccountSettings = require('../../../../pageObject/admin/login/accountSettings/index');
adminVariables and index are both javascript files.
It looks very ugly and I want to minimize it to make it more readable and elegant by reducing all the ../../../ (also my boss doesn't like it).
I've tried following the NPM docs found here: https://docs.npmjs.com/files/package.json#local-paths
but I'm slightly confused about using npm install --save. My page object directories do not have package.json files in them. Just simple js files that create classes and methods that I reference in my tests scripts. I get this error:
npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a package.json in
npm ERR! eisdir a package you are trying to install.
I thought maybe I can do it manually such as altering my package.json as:
{
"dependencies": {
"admin-variables": "file:./qe/adminVariables",
"admin-login": "file:./qe/pageObject/admin/login/index",
"header-profile": "file:./qe/pageObject/admin/login/common/headerProfile/index",
"account-settings": "file:./qe/pageObject/admin/login/accountSettings/index"
}
}
Then change the previous LOC to this:
var config = require('admin-variables');
var AdminLogin = require('admin-login');
var HeaderProfile = require('header-profile');
var AccountSettings = require('account-settings');
But when I try to run my test scripts I get the following error:
module.js:340
throw err;
^
Error: Cannot find module 'admin-variables'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/username/go/src/bitbucket.org/companyname/platform/qe/test/admin/dashboard/adminUser/pdvi-2361.js:7:14)
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:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at /Users/username/go/src/bitbucket.org/companyname/platform/qe/node_modules/mocha/lib/mocha.js:216:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/username/go/src/bitbucket.org/companyname/platform/qe/node_modules/mocha/lib/mocha.js:213:14)
at Mocha.run (/Users/username/go/src/bitbucket.org/companyname/platform/qe/node_modules/mocha/lib/mocha.js:453:10)
at Object.<anonymous> (/Users/username/go/src/bitbucket.org/companyname/platform/qe/node_modules/mocha/bin/_mocha:393:18)
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:313:12)
at Function.Module.runMain (module.js:457:10)
at startup (node.js:138:18)
at node.js:974:3
npm ERR! Darwin 15.2.0
npm ERR! argv "/usr/local/Cellar/node/5.1.1/bin/node" "/usr/local/bin/npm" "run" "env-production" "mocha" "test/admin/dashboard/adminUser/pdvi-2361.js" "--" "--reporter" "spec" "--slow" "0"
npm ERR! node v5.1.1
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! ui-tests#1.0.0 env-production: `env envVar='production' "mocha" "test/admin/dashboard/adminUser/pdvi-2361.js" "--reporter" "spec" "--slow" "0"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ui-tests#1.0.0 env-production script 'env envVar='production' "mocha" "test/admin/dashboard/adminUser/pdvi-2361.js" "--reporter" "spec" "--slow" "0"'.
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 ui-tests package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! env envVar='production' "mocha" "test/admin/dashboard/adminUser/pdvi-2361.js" "--reporter" "spec" "--slow" "0"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ui-tests
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ui-tests
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/username/go/src/bitbucket.org/companyname/platform/qe/npm-debug.log
npm ERR! Darwin 15.2.0
npm ERR! argv "/usr/local/Cellar/node/5.1.1/bin/node" "/usr/local/bin/npm" "run" "p-2361:spec"
npm ERR! node v5.1.1
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! ui-tests#1.0.0 p-2361:spec: `npm run env-production mocha test/admin/dashboard/adminUser/pdvi-2361.js -- --reporter spec --slow 0`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ui-tests#1.0.0 p-2361:spec script 'npm run env-production mocha test/admin/dashboard/adminUser/pdvi-2361.js -- --reporter spec --slow 0'.
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 ui-tests package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run env-production mocha test/admin/dashboard/adminUser/pdvi-2361.js -- --reporter spec --slow 0
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ui-tests
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ui-tests
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/username/go/src/bitbucket.org/companyname/platform/qe/npm-debug.log
Here is my directory structure that I work in (mostly qe/ folder).
platform/
qe/
node_modules/
pageObject/
admin/
login/
accountSettings/
index.js
common/
headerProfile/
index.js
dashboard/
index.js
index.js
test/
admin/
dashboard/
adminUser/
pdvi-2361.js
pdvi-2372.js
pdvi-2377.js
adminVariables.json
package.json
Here is an example of what my page object looks like:
var webdriver = require('selenium-webdriver');
var config = require('../../../adminVariables');
var adminVar = process.env.envVar;
var login = config[adminVar].adminLogin;
var user = config[adminVar].role.adminUser.name;
var email = config[adminVar].role.adminUser.email;
var pw = config[adminVar].role.adminUser.password;
class AdminLogin {
constructor(driver) {
this.driver = driver;
this.driver.manage().timeouts().implicitlyWait(2000);
this.emailField = this.driver.findElement({
css: 'input[name="email"]'
});
this.passwordField = this.driver.findElement({
css: 'input[name="password"]'
});
this.loginButton = this.driver.findElement({
css: 'button[type="submit"]'
});
}
fillEmail(email) {
this.emailField.sendKeys(email);
}
fillPassword(password) {
this.passwordField.sendKeys(password);
}
signin() {
this.loginButton.click();
}
}
module.exports = AdminLogin;
What would be the proper way to require these local json/javascript files in my code?

Categories