I am building a React app. I installed yargs and argsert manually by npm. For some reason, when I start the development server, I get the following error and stack trace. The two modules in question are listed clearly as argsert and yargs. I am unsure of how to proceed. Any feedback would be greatly appreciated.
webpack-dev-server --mode development
module.js:549
throw err;
^
Error: Cannot find module './lib/argsert'
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> (/home/josh/devel/react-app/frontend/node_modules/webpack-dev-server/node_modules/yargs/yargs.js:2:17)
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)
package.json
{
"name": "react-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --mode development",
"build": "webpack --mode production",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#babel/core": "^7.8.7",
"#babel/preset-env": "^7.8.7",
"#babel/preset-react": "^7.8.3",
"babel-loader": "^8.0.6",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
},
"dependencies": {
"argsert": "^1.0.9",
"babel-loader": "^8.0.6",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-router-dom": "^5.1.2",
"weak-key": "^1.0.1",
"yargs": "^15.3.1"
}
}
Use npm i argsert yargs if it is not working working try to npm install if even tough it is not working. Delete argsert and yargs from package.json and install it again.
I have installed node and npm from source and that seems to have fixed the issue. Thanks for the help everyone.
Related
i have created an app which i am running it on my windows pc and works fine. is a MERN application now i have seted up a machine with ubuntu so i can serve it. but i cant run the back end i have the following error:
import mongoose from "mongoose"; ^^^^^^^^ SyntaxError: Unexpected identifier at Module._compile (internal/modules/cjs/loader.js:723:23) 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) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)`
all node modules are installed,
node installed 10.19.0,
npm installed,
mongo db installed,
nodemodules installed,
"type":"module" is on json file:
{
"name": "myidea",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"serve": "npx nodemon index.js",
"seed": "node db/seeds.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.1.0",
"body-parser": "^1.20.1",
"crypto-js": "^4.1.1",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"gridfs-stream": "^1.1.1",
"jsonwebtoken": "^8.5.1",
"method-override": "^3.0.0",
"mongoose": "^6.6.5",
"mongoose-unique-validator": "^3.1.0",
"multer-gridfs-storage": "^5.0.2"
},
"type": "module"
}
But still when i do npm run serve or npm run seed i have the error above. what em i missing here?
i have tried npm run serve and npm run seed and still i am getting the same error despite the fact ii have added the "type":"module" on the json
I was working on a technical test in node js, and I got this error "Please install sqlite3 package manually" when I ran npm start.
I searched for the answer on the internet for several days. I tried npm rebuild, npm i sqlite3, updating node, and some other things
I suspect it has something to do with my mac M1, I've encountered compatibility issues in the past, but I could be wrong.
I use node v16.14.2 and sqlite3 3.36.0.
Any help would be appreciated
Here is the full error:
Error: Please install sqlite3 package manually
at ConnectionManager._loadDialectModule (/Users/arthur/Documents/candidate-takehome/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:55:15)
at new ConnectionManager (/Users/arthur/Documents/candidate-takehome/node_modules/sequelize/lib/dialects/sqlite/connection-manager.js:18:21)
at new SqliteDialect (/Users/arthur/Documents/candidate-takehome/node_modules/sequelize/lib/dialects/sqlite/index.js:13:30)
at new Sequelize (/Users/arthur/Documents/candidate-takehome/node_modules/sequelize/lib/sequelize.js:188:20)
at Object.<anonymous> (/Users/arthur/Documents/candidate-takehome/models/index.js:15:15)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
Here is my package json:
"name": "game-viewer-tool",
"version": "1.0.0",
"description": "Game Viewer Tool",
"main": "index.js",
"scripts": {
"start": "node index.js",
"eslint": "./node_modules/.bin/eslint .",
"test": "NODE_ENV=test node_modules/.bin/sequelize db:migrate; NODE_ENV=test ./node_modules/.bin/mocha --exit 'test/*.js'; rm ./database_test.sqlite3"
},
"license": "UNLICENSED",
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"sequelize": "^6.17.0",
"sequelize-cli": "^5.5.0",
"sqlite3": "^5.0.2"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-vue": "^5.2.3",
"expect": "^24.8.0",
"husky": "^1.3.1",
"jest": "^23.6.0",
"lint-staged": "^8.1.5",
"mocha": "^6.1.4",
"nodemon": "^1.18.10",
"sinon": "^7.3.2",
"supertest": "^4.0.2"
}
}
when I give npm start comand its show
internal/modules/cjs/loader.js:883
throw err:
Error: Cannot finde module'webpack-cli/bin/config-yargs'
plz help me to solve this problem
use os : windows 10
node version is v14.16.1
> chapter15.1#1.0.0 start
> webpack-dev-server
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- C:\Users\user\Desktop\JS full Course\chapter15.1\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\user\Desktop\JS full Course\chapter15.1\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\user\\Desktop\\JS full Course\\chapter15.1\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
}
webpack version 5.37.1
webpack-cli version 4.7.0
webpack-dev-server version 3.11.2
Package.json file is
{
"name": "chapter15.1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#babel/cli": "^7.14.3",
"#babel/core": "^7.14.3",
"#babel/node": "^7.14.2",
"#babel/polyfill": "^7.12.1",
"#babel/preset-env": "^7.14.2",
"#babel/register": "^7.13.16",
"babel-loader": "^8.2.2",
"babel-register": "^6.26.0",
"html-webpack-plugin": "^5.3.1",
"webpack": "^5.37.1",
"webpack-cli": "^4.7.0",
"webpack-dev-server": "^3.11.2"
}
}
In the Package.json file add a serve script like below and remove the start script. See the documentation.
{
"scripts": {
"serve": "webpack serve"
},
Then Run this command in your terminal.
npm run serve
I was getting Error: Cannot find module 'fabric-client'error then manually I ran 'npm install fabric-client#1.0.5' inside node_module then I am getting below error
[root#ip-172-31-61-27 controller]# node app.js module.js:538
throw err;
^
Error: Cannot find module 'cors'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/ec2-user/AWSNodeApp/controller/app.js:27:11)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
We already have an entry of 'cors' in the package.json file but still it given above error.
Below is the package.json file :-
{
"name": "awsnodeapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.538.0",
"body-parser": "^1.17.1",
"cors": "^2.8.3",
"express": "^4.15.2",
"express-session": "^1.15.2",
"fabric-ca-client": "1.3.0",
"fabric-client": "1.3.0",
"fs-extra": "^2.0.0",
"log4js": "^3.0.6",
"uuid": "^3.3.2",
"ws": "^6.1.0"
}
}
Since your app.js requires cors module, you need to install and add to package.json.
npm install cors --save
You can find the answer from this old post: Error: Cannot find module 'cors'
I have a app on Heroku and when I run node server.js it's throwing a error and saying Error: Cannot find module 'express'.
I've cleared the npm cache, rebuilt the app, checked the package.json & dependencies. Nothing much is working for me and I'm just looking for solutions now.
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/app/server.js:1:79)
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)
Trying to get the app to start.
Here's the package.json
{
"name": "SCOGEAgent",
"version": "0.0.0",
"description": "A simple Blockstack app",
"main": "index",
"scripts": {
"browserify": "browserify requires.js -o public/bundle.js",
"start": "run browserify & node server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/blockstack/hello-blockstack.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/blockstack/hello-blockstack/issues"
},
"homepage": "https://github.com/blockstack/hello-blockstack#readme",
"devDependencies": {
"browserify": "^14.1.0",
"express": "^4.16.4",
"opn": "^4.0.2"
},
"dependencies": {
"browserify": "^14.1.0",
"express": "^4.16.4",
"opn": "^4.0.2",
"#types/node": "^11.13.0",
"blockstack": "^18.0.4",
"express-ws": "^4.0.0",
"json-pointer": "^0.6.0",
"react-router-dom": "^5.0.0",
"socket.io": "^2.2.0",
"socket.io-client": "^2.2.0",
"websocket-stream": "^5.5.0"
}
}
Express should be in your dependencies not devDependencies. Here's how you know where to put your third-party dependencies.
Does the app need the dependency to run? Put it in dependencies
Does the app need the dependency to build, test, lint, or any other
task for development? Put it in devDependencies.
The only time this gets fuzzy is when you need to build the project before you run it. Then some of your build dependencies might be placed in dependencies instead of devDependencies. I'm sure there is a more professional way to manage this but that's how I do it.