The application can't find the module dist - javascript

I have a NodeJs Application and I try to start it in terminal using npm run start:prod. I receive the error:
Error: Cannot find module '../dist'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object.<anonymous>
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
npm ERR! errno 1
npm ERR! mern-starter#2.0.0 start:prod: `cross-env NODE_ENV=production node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mern-starter#2.0.0 start:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
And there is indeed no dist folder or file. What is it usually used for?
Do you know how it can be solved?

Related

Docker - Unable to run sqllite3 directory with knex.js using node.js

I'm trying to run Docker with node: 14.17.5-alpine using sqllite3 directory version 5.0.2
Everything works perfectly through my computer (WIN10) but as soon as I try to transfer it to Linux Docker I get an error:
According to what is written I need to install sqlite3 but the directory is in the package.json file
I read online to see what can be done about it but did not find an unequivocal answer
Does anyone encounter the issue and know how to solve the file problem found in the path "/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node"
> my-project#1.0.0 start /app
> node app.js
Knex: run
$ npm install sqlite3 --save
Cannot find module '/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node'
Require stack:
- /app/node_modules/sqlite3/lib/sqlite3-binding.js
- /app/node_modules/sqlite3/lib/sqlite3.js
- /app/node_modules/knex/lib/dialects/sqlite3/index.js
- /app/node_modules/knex/lib/knex-builder/internal/config-resolver.js
- /app/node_modules/knex/lib/knex-builder/Knex.js
- /app/node_modules/knex/lib/index.js
- /app/node_modules/knex/knex.js
- /app/config/database.js
- /app/app.js
Error: Cannot find module '/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node'
Require stack:
- /app/node_modules/sqlite3/lib/sqlite3-binding.js
- /app/node_modules/sqlite3/lib/sqlite3.js
- /app/node_modules/knex/lib/dialects/sqlite3/index.js
/app/node_modules/knex/lib/client.js:182
throw new Error(`${message}\n${e.message}`);
^
Error: Knex: run
$ npm install sqlite3 --save
Cannot find module '/app/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node'
Require stack:
- /app/node_modules/sqlite3/lib/sqlite3-binding.js
- /app/node_modules/sqlite3/lib/sqlite3.js
- /app/node_modules/knex/lib/dialects/sqlite3/index.js
- /app/node_modules/knex/lib/knex-builder/internal/config-resolver.js
- /app/node_modules/knex/lib/knex-builder/Knex.js
- /app/node_modules/knex/lib/index.js
- /app/node_modules/knex/knex.js
- /app/config/database.js
- /app/app.js
at Client_SQLite3.initializeDriver (/app/node_modules/knex/lib/client.js:182:13)
at new Client (/app/node_modules/knex/lib/client.js:71:12)
at new Client_SQLite3 (/app/node_modules/knex/lib/dialects/sqlite3/index.js:20:5)
at knex (/app/node_modules/knex/lib/knex-builder/Knex.js:12:28)
at Object.<anonymous> (/app/config/database.js:3:21)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Module.require (internal/modules/cjs/loader.js:666:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ms-node-passport#1.0.0 start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ms-node-passport#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! /root/.npm/_logs/2021-08-22T02_47_27_119Z-debug.log
- /app/node_modules/knex/lib/knex-builder/internal/config-resolver.js
- /app/node_modules/knex/lib/knex-builder/Knex.js
- /app/node_modules/knex/lib/index.js
- /app/node_modules/knex/knex.js
- /app/config/database.js
- /app/app.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:610:15)
at Function.Module._load (internal/modules/cjs/loader.js:526:27)
at Module.require (internal/modules/cjs/loader.js:666:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/app/node_modules/sqlite3/lib/sqlite3-binding.js:4:15)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Module.require (internal/modules/cjs/loader.js:666:19)

`webpack serve` fails with "Error: Cannot find module '../../lib/webpack-cli'"

I'm trying to set up a project using webpack. When I try to serve it using webpack I get this:
root#d690f9010746:~/chat-webapp# npm run serve
> chat-webapp#1.0.0 serve /root/chat-webapp
> webpack serve --config webpack.config.js
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '../../lib/webpack-cli'
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 (/root/chat-webapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/root/chat-webapp/node_modules/#webpack-cli/serve/index.js:4:20)
at Module._compile (/root/chat-webapp/node_modules/v8-compile-cache/v8-compile-cache.js:192: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)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chat-webapp#1.0.0 serve: `webpack serve --config webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chat-webapp#1.0.0 serve 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! /root/.npm/_logs/2020-05-31T19_42_42_752Z-debug.log
The line /root/chat-webapp/node_modules/#webpack-cli/serve/index.js:4 (mentioned in the stacktrace) says: const WebpackCLI = require("../../lib/webpack-cli");. But I don't have the file /root/chat-webapp/node_modules/lib/webpack-cli - and even if I did, it's not in the #webpack-cli/serve repo, and the repo shouldn't be making assumptions about the locations of files it doesn't control.
And yet I can't find anyone or stackoverflow or anywhere else who's getting an error on the same relative path. So what am I missing? I've installed all the npm repos locally, which is a bit non-standard - could it be something to do with that?

Why can node not find a module? (Even when I'm not requiring it)

I've been trying to import a js file in the same folder using require but I keep getting this error:
Error: Cannot find module 'player'
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> (/Users/shaham/Code/Typersion/server/items.js:1:14)
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)
Here's the code:
// server.js
var Player = require("./player")
//player.js
A bunch of functions...
module.exports = {
functionNames...
}
File architecture:
server/
-server.js
-player.js
I even get this error when trying to run node player.js
What am I doing wrong?
If you want a deeper look: here's the repo: https://github.com/ShahamNoorani/Typersion (you'll be looking for the refactoring branch).
I've tried to launch your code and there's my error message:
user#user ~/git/Typersion (git)-[refactoring] % npm start
> typersion#1.0.0 start /home/user/git/Typersion
> node server/server.js
internal/modules/cjs/loader.js:1023
throw err;
^
Error: Cannot find module 'player'
Require stack:
- /home/user/git/Typersion/server/items.js
- /home/user/git/Typersion/server/enemy.js
- /home/user/git/Typersion/server/server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1020:15)
at Function.Module._load (internal/modules/cjs/loader.js:890:27)
at Module.require (internal/modules/cjs/loader.js:1080:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/user/git/Typersion/server/items.js:1:14)
at Module._compile (internal/modules/cjs/loader.js:1176:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
at Module.load (internal/modules/cjs/loader.js:1040:32)
at Function.Module._load (internal/modules/cjs/loader.js:929:14)
at Module.require (internal/modules/cjs/loader.js:1080:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/user/git/Typersion/server/items.js',
'/home/user/git/Typersion/server/enemy.js',
'/home/user/git/Typersion/server/server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! typersion#1.0.0 start: `node server/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the typersion#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/user/.npm/_logs/2020-05-06T21_25_55_323Z-debug.log
It clearly says that there is a problem in the server/items.js file, even the lineno and colno is specified, so basically by looking into that file I can tell you forgot to add ./ before your imprt.
TLDR
change var Player = require("player") to var Player = require("./player") in server/items.js

Error: ENOENT: no such file or directory, `node src/index.js`

I am working in node Js. When im trying to load a file, with this lines:
key: fs.readFileSync('./localCerts/local.dev.key'),
cert: fs.readFileSync('./localCerts/local.dev.crt'),
This is error appeards when I try to rub application:
bou-frontend#0.0.1 start /Users/nikolatrajkovic/Desktop/projects/bou-frontend/bou-frontend
node src/index.js
fs.js:114
throw err;
^
Error: ENOENT: no such file or directory, open
'/Users/nikolatrajkovic/Desktop/projects/bou-frontend/bou-frontend/build/index.html'
at Object.openSync (fs.js:438:3)
at readFileSync (fs.js:343:35)
at Object. (/Users/nikolatrajkovic/Desktop/projects/bou-frontend/bou-frontend/src/ssr.js:34:22)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! bou-frontend#0.0.1 start: node
src/index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the
bou-frontend#0.0.1 start script. npm ERR! This is probably not a
problem with npm. There is likely additional logging output above.
PACKAGE.json file:
scripts": {
"start": "node src/index.js",
}
Any advice or help is welcome.

Node Js Error Module.js 549

While starting my application, I get this error. I have already checked and seen that the required module is well installed, and also gave it global access.
Hussains-MacBook-Pro:NodeRest-Shop Hussain$ npm start
> noderest-shop#1.0.0 start /Users/Hussain/Desktop/Development/Web/NodeRest-Shop
> nodemon server.js
module.js:549
throw err;
^
Error: Cannot find module 'binary-extensions'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/Hussain/Desktop/Development/Web/NodeRest-Shop/node_modules/is-binary-path/inde
x.js:3:24)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! noderest-shop#1.0.0 start: `nodemon server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the noderest-shop#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! /Users/Hussain/.npm/_logs/2018-06-25T05_23_59_594Z-debug.log
You're missing the binary-extensions module, as seen in your log:
Error: Cannot find module 'binary-extensions'
It could be that you're missing some dependencies or forgot to include it.
You can install it using npm:
npm install binary-extensions
And include binaryExtensions in your project:
const binaryExtensions = require('binary-extensions');
I fixed this issue by running:
npm i npm#latest -g
Check your app.js file your index route should be
app.use(require('./routes/')); not app.use(require('./routes/index'));

Categories

Resources