Sails lift error 'Cannot find module 'express/node_modules/cookie' - javascript

I am trying to create my first sails app and I've followed the steps on the sails getting started (http://sailsjs.org/get-started). But when i try to do a sails lift, i get the following error:
(node:11291) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
module.js:442
throw err;
^
Error: Cannot find module 'express/node_modules/cookie'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/master/Desktop/Developer/NodeJS/HelloSails/node_modules/sails/lib/hooks/session/index.js:9:12)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at /Users/master/Desktop/Developer/NodeJS/HelloSails/node_modules/sails/lib/app/configuration/index.js:54:28
at Function.reduce (/Users/master/Desktop/Developer/NodeJS/HelloSails/node_modules/sails/node_modules/lodash/dist/lodash.js:3735:25)
at Configuration.defaultConfig (/Users/master/Desktop/Developer/NodeJS/HelloSails/node_modules/sails/lib/app/configuration/index.js:53:18)
at Configuration.bound [as defaults] (/Users/master/Desktop/Developer/NodeJS/HelloSails/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
I tried manually removing the 'node_modules' folder, inserting express as a dependency in my package.json and running 'npm install', but that did not work.
Im running Node v6.2.2 Sail v0.10.5 and NPM v3.10.6
What am i missing here?

update sails version to latest, it is issue of npm structure, old version use tree level dependency while new version use same level structure
sails upgrade version

It's a dependency issue with npm, this worked for me when I had the issue.
npm -g install npm#latest

Related

npm rebuild doesn't work when trying to fix different node module version error

I'm getting an error where the better_sqlite3 package is using a different version of node, and it says to try npm rebuild and npm install but this doesn't solve anything and I'm still getting the same error.
/home/nonce/Documents/Repositories/test/node_modules/bindings/bindings.js:121
throw e;
^
Error: The module '/home/nonce/Documents/Repositories/test/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 102. This version of Node.js requires
NODE_MODULE_VERSION 93. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
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)
at require (node:internal/modules/cjs/helpers:102:18)
at bindings (/home/nonce/Documents/Repositories/test/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/home/nonce/Documents/Repositories/test/node_modules/better-sqlite3/lib/database.js:9:24)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
code: 'ERR_DLOPEN_FAILED'
}
I don't think this is an error with better-sqlite3 itself, since I've done some research and a lot of people have gotten this sort of error, and the general solution is to execute npm rebuild but for me this doesn't do anything.
Solved the issue, I was using an outdated version of node as I was using node v16.13.2 so I tried switching to the most latest version (v17.4.0 as of now) and it works like a charm now.

Node js: Error: Cannot find module 'mime-types/node_modules/mime-db'

I followed a tutorial to create a CRUD App with Nodejs, I finished the project and everything worked fine. After I tried to move all the files and folders to a new folderand I destroyed everything.
Now when I try to run node app.js the following happen:
enter code herinternal/modules/cjs/loader.js:797
throw err;
^
Error: Cannot find module 'mime-types/node_modules/mime-db'
Require stack:
- C:\Users\Costis\Documents\Code\Vue\Mongodb_app\server\node_modules\mime-types\index.js
- C:\Users\Costis\Documents\Code\Vue\Mongodb_app\server\node_modules\accepts\index.js
- C:\Users\Costis\Documents\Code\Vue\Mongodb_app\server\node_modules\express\lib\request.js
- C:\Users\Costis\Documents\Code\Vue\Mongodb_app\server\node_modules\express\lib\express.js
- C:\Users\Costis\Documents\Code\Vue\Mongodb_app\server\node_modules\express\index.js
- C:\Users\Costis\Documents\Code\Vue\Mongodb_app\server\app.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\Users\Costis\Documents\Code\Vue\Mongodb_app\server\node_modules\mime-types\index.js:15:10)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:849:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Costis\\Documents\\Code\\Vue\\Mongodb_app\\server\\node_modules\\mime-types\\index.js',
'C:\\Users\\Costis\\Documents\\Code\\Vue\\Mongodb_app\\server\\node_modules\\accepts\\index.js',
'C:\\Users\\Costis\\Documents\\Code\\Vue\\Mongodb_app\\server\\node_modules\\express\\lib\\request.js',
'C:\\Users\\Costis\\Documents\\Code\\Vue\\Mongodb_app\\server\\node_modules\\express\\lib\\express.js',
'C:\\Users\\Costis\\Documents\\Code\\Vue\\Mongodb_app\\server\\node_modules\\express\\index.js',
'C:\\Users\\Costis\\Documents\\Code\\Vue\\Mongodb_app\\server\\app.js'
]e
Any suggestion?
You probably have to make a clean install your dependencies again with npm install, as you might have broken some symlinks (just assuming as I'm not a Windows user).
You can manually delete your node_modules folder and run npm install, or if you have an existing package-lock.json, use npm ci to install exactly the same versions of deps you had before.

React: "react-scripts start" cannot find module webpack

I am getting this error when I am not even using webpack in this particular branch. I have never encountered this error in my main branch before. However, I wanted to learn webpack so I created a webpack branch of my project and install webpack in that branch(Assuming that I did correctly install webpack locally). Now when I switch back to my main, and tried to run "npm start". I am getting into this error.
> react-scripts start
module.js:550
throw err;
^
Error: Cannot find module 'webpack'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\pzheng\my-app\node_modules\webpack-dev-server\lib\Server.js:22:17)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
When I tried to run "npm run build", this error appears instead:
Error: Cannot find module 'webpack/lib/Chunk'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\pzheng\my-app\node_modules\extract-text-webpack-plugin\dist\index.js:17:14)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\pzheng\my-app\node_modules\extract-text-webpack-plugin\dist\cjs.js:3:18)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
Many SO posts suggesting downloading webpack, but I do not wish to use webpack for this branch, so many SO posts are not helpful.
What I have tried:
I checked my package.json file, there is no webpack dependency in my main branch. However, I do see webpack in my package.lock.json file when I search for the word webpack
What I am using:
I am using create-react-app library.
What I need help with:
I am trying to figure out the cause of this error and how to fix it. Does it have to do with me installing webpack in the other branch?
I faced this when I was trying to use react-scripts in an existing react app that wasn't scaffolded using create-react-app. The problem was the package-lock file. Deleting node_modules and package-lock.json and running npm install did the trick for me.
Ok, this is weird but this is how I fixed it.
I think this error has to do with "react-script"
I was using react-script#1.3, as soon as I upgrade my react script to 2.1.3, which is the latest version published 4 days ago, this error is fixed.
You are using CRA (Create React App) which is already using webpack (with it's own config file). CRA offers the option to 'eject', which will expose the webpack config file that you can then modify and play with. If you do choose to eject, do so on another branch (in case you decide to go back). Be aware that ejecting is non-reversible.
Hope this helps!

Getting an error when installing Gulp js

I'm trying to install Gulp js on my computer.
I think it is installed but not completely because when I run gulp -v in powershell it returns these lines:
[12:43:04] CLI version 1.3.0
[12:43:04] Local version 3.9.1
But when I want to run .\node-setup.cmd it throws the following error:
Error: Cannot find module 'gulp-autoprefixer'
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:\LOBOS\FDD.WAP\gulpfile.js:5:20)
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)
Press any key to continue . . .
Any ideas how to solve this?
most likely you have gulp-autoprefixer as a dependency in the package.json file of your project but you did not install it locally.
try to run npm install from the command line and see if it fix your issue.
The problem wouldn't be solved if I would install gulp-autoprefixer because afterwards it would require another module and after that another module and so on...
The solution was to deprecate the package.json file by changing the react-bootstrap-table from my version (2.8.2) to version 4.0.0-beta.2. By doing so, the json file will have a version which is not depending on react-toastr.

module.js:327 Error: Cannot find module 'express'

Hello I am new in a nodejs and when I run any file in command prompt like:-
C:\demoData>node demo.js
I get error li9ke this
module.js:327
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\demoData\shahzad.js:1:77)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
I did R&D and get the solution
npm install express
And my Problem has solved using this. But Why I required this I have already express folder globally.this path
C:\Users\broswire\AppData\Roaming\npm\node_modules;
I want to use this node_modules, I don't want locally node_modules.
Node encourages using locally installed modules. Generally, using modules installed with npm install --global or npm install -g should be reserved for cli tools and things used systemwide. So to use express in a project, it is recommended to npm install express in that directory. It is also useful to add a package.json file to save the versions of your dependencies. Then you can just navigate to your project and run npm install and it will install the required dependencies.

Categories

Resources