I'm experiencing the following error when I try to run my Node.js app:
Starting child process with 'node ./app.js'
C:\Users\Julian\OneDrive\Documents\Websites\Node\node_modules\connect-redis\lib\connect-redis.js:33
var Store = connect.session.Store;
^
TypeError: Cannot read property 'Store' of undefined
at module.exports (C:\Users\Julian\OneDrive\Documents\Websites\Node\node_modules\connect-redis\lib\connect-redis.js:33:30)
at Object.<anonymous> (C:\Users\Julian\OneDrive\Documents\Websites\Node\app.js:9:42)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
Program node ./app.js exited with code 1
Starting child process with 'node ./app.js'
Received SIGINT, killing child process...
Parent process exiting, terminating child...
Terminate batch job (Y/N)? y
My package.json file is as follows:
{
"name": "NodeChat",
"version": "0.0.0",
"main": "app.js",
"scripts": {
"stop": "echo not implemented",
"start": "supervisor ./app.js"
},
"dependencies": {
"connect-flash": "0.1.1",
"connect-redis": "1.4.7",
"cookie-parser": "1.4.3",
"ejs": "0.8.5",
"express": "4.6.1",
"express-partials": "0.2.0",
"express-session": "1.14.2",
"redis": "0.10.1"
}
}
I thought it might be a compatibility issue, but I believe I'm running a compatible version of connect-redis#1.4.7. I have an instance of Redis running.
Updating "connect-redis": "1.4.7" to 1.5.0 solved the problem for me.
Related
Currently converting my project from JS to TS, working on the server side. Here is the error code.
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module
'/Users/steven/Documents/codingDojo/Mern/tomrotten/server/index.js'
at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain]
(internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
[nodemon] app crashed - waiting for file changes before starting...
here are a list of my dependencies:
"dependencies": {
"#material-ui/lab": "^4.0.0-alpha.58",
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-session": "^1.17.1",
"jsonwebtoken": "^8.5.1",
"mysql": "^2.18.1",
"mysql2": "^2.2.5",
"sequelize": "^6.5.0",
"sqlite3": "^5.0.1"
This happens because it is missing a dependency, either because the dependency is not imported, or it is but it isn't installed. Do you have import cjr from "cjr" or something like that at the top of server/index.js? Have you done npm install?
I have protractor running with typescript and I'm trying to follow the steps on the link
Using require with relative paths
so i can test drag and drop with native javascript from this repo https://gist.github.com/druska/624501b7209a74040175 because there is an issue with Chromedriver and it's not working.
Package.json
"dependencies": {
"#types/jasmine": "^3.5.10",
"#types/node": "^13.11.0",
"dragndrop": "./src/utils/functions/dragndrop/",
"protractor": "^5.4.4",
"typescript": "^3.8.3"
},
Package.json of the module
{
"name": "dragndrop",
"version": "0.1.1",
"description": "Drag and drop object",
"main": "./index.js",
"dependencies": {}
}
This is what I have in my code
var DragAndDrop = require('dragndrop');
var dragAndDropFn = new DragAndDrop();
...
browser.executeScript(dragAndDropFn, elem2, elem1);
When I run the test I get
E/launcher - Error: Error: Cannot find module 'dragndrop'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (C:\Work\GIT\OSM\Web\temp\src\test-suites\feature\routes-planning\routes-planning-list.spec.js:17:19)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Can someone tell what do I need to do/change in order to use the javascript module?
Thanks in advance
I'm getting an error on the start command when using react-native. The file
projectName/node_modules/#babel/core/lib/transformation/file/file.js
on line 63 is giving the error
constructor(options, {
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Module._extensions..js (module.js:417:10)
at Object.require.extensions.(anonymous function) [as .js] (/home/cread/WHOOP-ReactNative/whoopApp/node_modules/babel-register/lib/node.js:152:7)
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/cread/WHOOP-ReactNative/whoopApp/node_modules/#babel/core/lib/index.js:123:36)
at Module._compile (module.js:410:26)
Here is my package.json file
{
"name": *name*,
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.0-alpha.2",
"react-native": "0.54.2",
"react-native-elements": "^0.19.1",
"react-native-keyboard-aware-scroll-view": "^0.5.0",
"react-native-modal-dropdown": "^0.6.2",
"react-native-sound": "0.10.9",
"react-native-vector-icons": "^4.5.0",
"react-navigation": "^1.5.8"
},
"devDependencies": {
"babel-jest": "23.0.0-alpha.0",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.2",
"react-test-renderer": "16.3.0-alpha.2"
},
"jest": {
"preset": "react-native"
}
}
I've tried deleting my node_modules file, clearing the npm cache, and reinstalling but to no avail. The problem seems to be in the cli.js file.
I was using the last version of the react-native and nodejs. Unfortunately, I needed to go back to the version 8.11.2. In my case, it is resolved.
I removed the node_modules dir.
$ rm -rf node_modules
$ nvm install 8.11.2
$ nvm use 8.11.2
$ npm install react-native#0.54.1
I'm new to electron and have made my first electron application, it runs normally running npm start but when using npm run I am unable to execute my application. (I am running ubuntu linux) The cli gives this error message when running the executable file:
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module '/home/user/Documents/dev/cocoa/cocoa-linux-x64/resources/app/index.js'
at Module._resolveFilename (module.js:455:15)
at Function.Module._resolveFilename (/home/user/Documents/dev/cocoa/cocoa-linux-x64/resources/electron.asar/common/reset-search-paths.js:35:12)
at Function.Module._load (module.js:403:25)
at Object.<anonymous> (/home/user/Documents/dev/cocoa/cocoa-linux-x64/resources/electron.asar/browser/init.js:171:8)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
This is my package.json :
{
"name": "cocoa",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "electron main.js",
"package-linux" : "electron-packager . --platform=linux --arch=x64 --electron-version=1.4.13"
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron-packager": "^8.7.1"
}
}
this is the main.js file :
const electron = require('electron')
const {app, BrowserWindow} = electron
app.on('ready', ()=> {
let win = new BrowserWindow({
width:400,
height:400
})
win.loadURL('http://google.com')
})
Does anyone know what I am doing wrong, thank you for your help.
Ok, that was really stupid. I had named the main js file for the project main.js when in actual fact it had to be named index.js
problem solved!
I have the following setup and have an issue with my error/stack trace am i missing something ?
package.json looks like:
{
"name": "xxxxxx",
"main": "server.js",
"private": true,
"scripts": {
"start": "nodemon --exec ./node_modules/.bin/babel-node server.js"
},
"dependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.6.5",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-runtime": "^6.6.1"
}
}
.babelrc looks like:
{
presets: ["es2015", "stage-0", "react"],
sourceMap: 'inline',
retainLines: true
}
server.js looks like:
let aVar = '';
throw new Error('some error');
import errorHandler from './app/middlewares/error_handler';
My stack trace is crazy
module.js:341
throw err;
^
Error: Cannot find module 'bugsnag'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/home/projectName/lib/util/error.js:14:113)
at Module._compile (module.js:413:34)
at loader (/home/projectName/node_modules/babel-register/lib/node.js:126:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/projectName/node_modules/babel-register/lib/node.js:136:7)
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/projectName/app/middlewares/error_handler.js:11:91)
at Module._compile (module.js:413:34)
at loader (/home/projectName/node_modules/babel-register/lib/node.js:126:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/projectName/node_modules/babel-register/lib/node.js:136:7)
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/projectName/server.js:15:22)
at Module._compile (module.js:413:34)
As you can see this does not look right and really hard to follow. i am sure there's a way to fix that.
It looks like you are missing 'bugsnag' module.
Try:
npm install -g bugsnag