I am getting the following error on executing command: npm start
Cannot find module 'loadash'
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> (<Path...>/data/dbConnector.js:3:1)
at Module._compile (module.js:643:30)
at loader (<Path...>\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (<Path...>\node_modules\babel-register\lib\node.js:154:7)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (<Path...>/data/resolvers.js:2:1)
at Module._compile (module.js:643:30)
at loader (<Path...>\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (<Path...>\node_modules\babel-register\lib\node.js:154:7)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
[nodemon] app crashed - waiting for file changes before starting...
package.json file:
{
"name": "essentials",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon ./index.js --exec babel-node -e js"
},
"author": "test",
"license": "ISC",
"dependencies": {
"casual": "^1.5.19",
"express": "^4.16.3",
"express-graphql": "^0.6.12",
"graphql": "^0.13.2",
"graphql-tools": "^2.23.1",
"loadash": "^1.0.0",
"mongoose": "^5.0.12",
"nodemon": "^1.17.2",
"sequelize": "^4.37.5",
"sqlite3": "^4.0.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-0": "^6.24.1"
}
}
I followed the below links but still none of them are working for me.
https://stackoverflow.com/questions/27431187/cannot-find-module-lodash
https://stackoverflow.com/questions/27431187/cannot-find-module-lodash/36618374
Also I see the below warning message:
Problems loading reference 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to load schema from 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to connect to https://schemastore.azurewebsites.net/schemas/json/package.json. Error: self signed certificate in certificate chain
Can anyone help me to fix this issue?
The package name should be lodash, not loadash.
After you correct that in packages.json you need to execute npm install.
Related
After updating to the latest dependencies my Firebase Functions backend won't run in either firebase emulators:start or firebase functions:shell. It fails with the following exception
- C:\Users\yannk\AppData\Roaming\npm\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\Project\projdir\firebase\functions\node_modules\firebase-admin\lib\firebase-namespace.js:23:20)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19) {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [23304] Error in handleMessage: {\"frb\":{\"cwd\":\"C:\\\\Project\\\\projdir\\\\firebase\\\\functions\",\"projectId\":\"snapdiscover-luminarcom\",\"triggerId\":\"\",\"emulators\":{\"firestore\":{\"name\":\"firestore\",\"host\":\"192.168.112.113\",\"port\":8080,\"pid\":23900},\"auth\":{\"name\":\"auth\",\"host\":\"192.168.112.113\",\"port\":9099}},\"adminSdkConfig\":{\"databaseURL\":\"https://snapdiscover-luminarcom.firebaseio.com\",\"storageBucket\":\"snapdiscover-luminarcom.appspot.com\"},\"socketPath\":\"\\\\\\\\?\\\\pipe\\\\C:\\\\Project\\\\projdir\\\\firebase\\\\functions\\\\23304\"},\"opts\":{\"nodeBinary\":\"C:\\\\Program Files\\\\nodejs\\\\node.exe\",\"env\":{}}} => Error: Cannot find module './auth/credential'\nRequire stack:\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\firebase-namespace.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\default-namespace.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\index.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\apps.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\providers\\database.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\index.js\n- C:\\Users\\yannk\\AppData\\Roaming\\npm\\node_modules\\firebase-tools\\lib\\emulator\\functionsEmulatorRuntime.js: Error: Cannot find module './auth/credential'\nRequire stack:\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\firebase-namespace.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\default-namespace.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\index.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\apps.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\providers\\database.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\index.js\n- C:\\Users\\yannk\\AppData\\Roaming\\npm\\node_modules\\firebase-tools\\lib\\emulator\\functionsEmulatorRuntime.js\n at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)\n at Function.Module._load (internal/modules/cjs/loader.js:690:27)\n at Module.require (internal/modules/cjs/loader.js:852:19)\n at require (internal/modules/cjs/helpers.js:74:18)\n at Object.<anonymous> (C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\firebase-namespace.js:23:20)\n at Module._compile (internal/modules/cjs/loader.js:959:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)\n at Module.load (internal/modules/cjs/loader.js:815:32)\n at Function.Module._load (internal/modules/cjs/loader.js:727:14)\n at Module.require (internal/modules/cjs/loader.js:852:19)"}}
[warn] ! functions: Cannot find module './auth/credential'
Require stack:
- C:\Project\projdir\firebase\functions\node_modules\firebase-admin\lib\firebase-namespace.js
- C:\Project\projdir\firebase\functions\node_modules\firebase-admin\lib\default-namespace.js
- C:\Project\projdir\firebase\functions\node_modules\firebase-admin\lib\index.js
- C:\Project\projdir\firebase\functions\node_modules\firebase-functions\lib\apps.js
- C:\Project\projdir\firebase\functions\node_modules\firebase-functions\lib\providers\database.js
- C:\Project\projdir\firebase\functions\node_modules\firebase-functions\lib\index.js
I have tried
Update everything to the latest dependencies (using ncu -u)
Assured that admin.initializeApp() is called
index.ts
import * as admin from 'firebase-admin'
admin.initializeApp()
[...]
I've also tried to initialize the app explicitly
index.ts
import { ServiceAccount, initializeApp, credential } from 'firebase-admin'
import * as serviceAccount from './api-key.json'
initializeApp({
credential: credential.cert(<ServiceAccount>{
projectId: serviceAccount.project_id,
clientEmail: serviceAccount.client_email,
privateKey: serviceAccount.private_key
})
})
[...]
Both give the same error. I need to test my code before deploying it to the backend.
Any help or hint is appreciated. Thanks
Edit: Now I get a new error:
[warn] ! TypeError: util.assign is not a function
at Object.<anonymous> (C:\Project\projdir\firebase\functions\node_modules\qs\lib\formats.js:13:23)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\Project\projdir\firebase\functions\node_modules\qs\lib\utils.js:3:15)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10) {"metadata":{"emulator":{"name":"functions"},"message":"TypeError: util.assign is not a function\n at Object.<anonymous> (C:\\Project\\projdir\\firebase\\functions\\node_modules\\qs\\lib\\formats.js:13:23)\n at Module._compile (internal/modules/cjs/loader.js:959:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)\n at Module.load (internal/modules/cjs/loader.js:815:32)\n at Function.Module._load (internal/modules/cjs/loader.js:727:14)\n at Module.require (internal/modules/cjs/loader.js:852:19)\n at require (internal/modules/cjs/helpers.js:74:18)\n at Object.<anonymous> (C:\\Project\\projdir\\firebase\\functions\\node_modules\\qs\\lib\\utils.js:3:15)\n at Module._compile (internal/modules/cjs/loader.js:959:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)"}}
This is my package.json
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log",
"test": "mocha --reporter spec"
},
"engines": {
"node": "10"
},
"main": "lib/index.js",
"dependencies": {
"#types/axios": "^0.14.0",
"axios": "^0.21.1",
"bad-words": "^3.0.4",
"capitalize-sentence": "^0.1.5",
"crypto": "^1.0.1",
"firebase-admin": "^9.6.0",
"firebase-functions": "^3.13.2",
"firebase-tools": "^9.8.0",
"perspective-api-client": "^3.1.0",
"qs": "^6.10.1"
},
"devDependencies": {
"firebase-functions-test": "^0.2.3",
"mocha": "^8.3.2",
"tslint": "^5.20.1",
"typescript": "^4.2.3"
},
"private": true
}
I am trying IBM Watson's Speech to Text API. While running my NodeJS app I get this.
I am using line-in package for streaming the input audio data in output, in addition to IBM Watson's SpeechToText package.
I tried removing node_modules and $ npm install and $ npm rebuild. Nothing worked.
node app.js
internal/modules/cjs/loader.js:718
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: Module did not self-register.
at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
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 Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (F:\Topgear\SpeechToText\node_modules\line-in\index.js:2:20)
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)```
package.json
{
"name": "SpeechToText",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"dotenv": "^8.0.0",
"line-in": "^0.1.2",
"watson-developer-cloud": "^4.0.1"
},
"devDependencies": {},
"scripts": {
"test": "mocha"
},
"keywords": [],
"author": "Nikhilesh AS",
"license": "ISC"
}
I have following error when trying to run my app on Heroku
Error: Cannot find module 'babel-core/register'
2017-11-13T10:42:19.749689+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:469:15)
2017-11-13T10:42:19.749690+00:00 app[web.1]: at Function.Module._load (module.js:417:25)
2017-11-13T10:42:19.749691+00:00 app[web.1]: at Module.require (module.js:497:17)
2017-11-13T10:42:19.749691+00:00 app[web.1]: at require (internal/module.js:20:19)
2017-11-13T10:42:19.749692+00:00 app[web.1]: at Object.<anonymous> (/app/bootstrap.js:1:63)
2017-11-13T10:42:19.749692+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-11-13T10:42:19.749693+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-11-13T10:42:19.749694+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-11-13T10:42:19.749694+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-11-13T10:42:19.749695+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
My package.json file is:
{
"name": "birdbase",
"version": "1.0.0",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.18.0"
},
"dependencies": {
"babel-register": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.18.0",
"bell": "^8.7.0",
"hapi": "^16.0.1",
"hapi-auth-jwt": "^4.0.0",
"jsonwebtoken": "^8.1.0",
"knex": "^0.14.0",
"mysql": "^2.14.1",
"node-uuid": "^1.4.8"
},
"scripts": {
"start": "node bootstrap.js"
}
}
and my app is based on the following tutorial:
https://scotch.io/tutorials/making-a-restful-api-with-hapi-js
src: https://github.com/labsvisual/hapijs-birds-api
So package.json dependencies are same as in devDependencies (as was indicated on other Stack Overflow issues).
Any idea why there is an error?
I keep getting this error when deploying my Node and Mean app to Heroku. The app seems to work normally when I run it locally but does not like it when I push it to Heroku.
module.js:471
throw err;
^
Error: Cannot find module 'lodash/keys'
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> (/app/node_modules/mongoose/node_modules/async/internal/iterator.js:16:13)
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)
This is my package.json file
{
"name": "utdknow",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.6.12",
"body-parser": "^1.14.1",
"crypto-js": "^3.1.8",
"ejs": "^2.3.4",
"express": "^4.13.3",
"lodash": "^4.17.3",
"lodash.keys": "^4.2.0",
"moment": "^2.17.0",
"mongoose": "^4.2.5",
"ng-file-upload": "^12.0.4"
}
}
It seems like modules are not correctly installed. Try cleaning cache and deploy your app to re-install all dependencies:
https://github.com/heroku/heroku-repo
heroku plugins:install heroku-repo
heroku repo:purge_cache --app appname
I am failing to start my node-based application on Openshift. The application starts OK locally but node's automatic deployment (on push to the remote master repo) hits a cyclic problem with the log;
DEBUG: Running node-supervisor with
DEBUG: program './app/server.js'
DEBUG: --watch '/var/lib/openshift/53dab282e0b8cdd367000131/app-root/data/.nodewatch'
DEBUG: --ignore 'undefined'
DEBUG: --extensions 'node|js|coffee'
DEBUG: --exec 'node'
DEBUG: Starting child process with 'node ./app/server.js'
DEBUG: Watching directory '/var/lib/openshift/53dab282e0b8cdd367000131/app-root/data/.nodewatch' for changes.
module.js:340
throw err;
^
Error: Cannot find module 'underscore.string'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/lib/openshift/53dab282e0b8cdd367000131/app-root/runtime/repo/node_modules/sequelize/lib/utils.js:5:26)
at Module._compile (module.js:456:26)
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 Module.require (module.js:364:17)
DEBUG: Program node ./app/server.js exited with code 8
DEBUG: Starting child process with 'node ./app/server.js'
module.js:340
throw err;
^
Error: Cannot find module 'underscore.string'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/lib/openshift/53dab282e0b8cdd367000131/app-root/runtime/repo/node_modules/sequelize/lib/utils.js:5:26)
at Module._compile (module.js:456:26)
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 Module.require (module.js:364:17)
DEBUG: Program node ./app/server.js exited with code 8
...this loop continues indefinitely, the app reports "Started" but clearly it's failed to initialize sequelize.js.
I'm a bit lost and loosing the faith in Openshift hosting at this point. I think this might be the last straw. Any advice?
Here is my app's package.json;
{
"name": "OceanLife-API",
"version": "1.1.0",
"description": "OceanLife API",
"keywords": [
"OceanLife",
"API",
"tide",
"swell",
"weather"
],
"author": {
"name": "David Branton",
"email": "oceanlife.development#gmail.com",
"url": "http://oceanlifeapi-brantapps.rhcloud.com/"
},
"homepage": "http://oceanlifeapi-brantapps.rhcloud.com/",
"repository": {
"type": "git",
"url": "https://github.com/openshift/origin-server"
},
"engines": {
"node": ">= 0.10.25",
"npm": ">= 1.3.24"
},
"dependencies": {
"express": "~3.4.8",
"sleep": "~1.1.8",
"aglio": "~1.14.0",
"sequelize": "~1.7.10",
"lodash": "~2.4.1",
"mysql": "~2.4.3",
"cheerio": "~0.17.0",
"moment": "~2.9.0",
"moment-timezone": "~0.2.5",
"tzwhere": "~1.0.0",
"line-reader": "~0.2.4"
},
"scripts": {
"lint": "./node_modules/.bin/jshint app/**/*.js",
"pretest": "npm run-script lint",
"test": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --recursive -R spec"
},
"devDependencies": {
"istanbul": "~0.3.5",
"rewire": "~2.1.3",
"sinon": "~1.12.2",
"mocha": "~2.1.0",
"nock": "~0.57.0",
"dredd": "~0.3.14",
"jshint": "~2.5.11"
},
"bundleDependencies": [],
"private": true,
"main": "./app/server.js"
}
I've come back to this recently and have managed to get it working by using the community built Node v0.12 cartridge. If you are having similar issues I'd recommend ditching the "official" Node v0.1 app cartridge and trying again.
Sweet - free hosting of my node app! :D