after webpack i got error Cannot find module 'resolve-cwd'? - node.js

**I got error while webpack**
error is :
webpack
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'resolve-cwd'
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> (/usr/share/nodejs/webpack/node_modules/import-local/index.js:3:20)
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)
please help me to resolved this problem.
I tried this one
npm install resolve-cwd .
still i am getting same issues after type webpack.i also delete node_module folder and package_json_lock file and npm install .after this run webpack still got same above error .
node --version
v10.19.0
npm --version
7.10.0

I'm not entirely sure why this happened. But I can speculate that it is due to old webpack version.
I've faced this issue right now.
I had installed webpack using apt (on Ubuntu 20.04.2 (Focal Fossa)).
Reinstalling webpack using npm resolved the issue.
Steps I followed:
$ rm $(which webpack); # removes the currently installed webpack
# you can replace $(which webpack) with the webpack location
$ npm i -g webpack webpack-cli

Despite installing the missing module 'resolve-cwd' it kept failing with another missing module.
I had to delete the node_modules folder then re-running the npm install command to install dependencies. This worked for me

I had the same issue with Resolve-CwD. But in my case it was caused by yarn not installing webpack properly.
You have an older version of node so try updating it and see if the above steps are working.
If it's not working then i'd say you try an older version of Ruby until the current issue with har-validator is sorted
In my case the error was caused because yarn was using har-validatior which is deprecated and just couldn't install webpack completely

In my case, showed me this too
So I just installed the cwd module with: npm install resolve-cwd.
And it fixed my problem.

If you are using ubuntu just add sudo before the 'webpack' command. In my case, this omission caused an error with 'resolve-cwd'

Related

Cannot find module 'findup-sync' on running grunt

I am working in a project previously built. This project was built using Node and Grunt.
I have a Gruntfile.js in the root folder of the project.
I installed grunt both locally and global, using
npm i grunt
npm i -g grunt
After, I installed grunt-cli both locally and global, using
npm i grunt-cli
npm i -g grunt-cli
And when I try to run any grunt command (develop, init, etc), I get the error
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'findup-sync'
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:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/usr/lib/nodejs/grunt-cli/bin/grunt:8:14)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787: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)
I searched in many forums and here too, but I haven't found an answer.
Can anybody help me?
UPDATE
After lose more than 24 hours working on this error, I fixed it with the following steps:
Install node-grunt-cli in Ubuntu via apt, like CPBL says in his comment
apt install node-grunt-cli
On OSX this wasn't necessary.
Following the steps I found on this blog. However, I also needed to run the command
grunt develop
as a sudo, even though changing the permissions of many folders.
Thanks to Pablo Lopes for putting me on the right track (see his question which includes the answer). I resolved my issue by:
Installing node-grunt-cli via apt:
sudo apt install node-grunt-cli
Running grunt with sudo:
sudo grunt
This isn't an ideal fix because it requires using sudo when running grunt - which shouldn't be necessary.
For me, installing via apt was the cause of the issue. Installing via npm npm install grunt -g corrected the problem. Given an existing global grunt install from apt, you might need to add --force to overwrite.

Error: Cannot find module 'commander'

when I m running sails -v, sails lift or even installing npm I m getting this error Please help -
Error: Cannot find module 'commander'
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> (/usr/local/lib/node_modules/sails/bin/_commander.js:6:15)
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)
Most likely commander is missing from package.json. Install it and add it to package.json by doing:
npm install commander --save
Install commander globally.
sudo npm install commander -g
This will install commander module under/usr/lib/node_modules/.
Uninstalling sails and reinstalling with 'sudo' resolved it.
npm uninstall sails -g
sudo npm install sails -g
When i try setup new app with the help of express-generator.
given error:Cannot find module 'commander'
Node version:12.16.1
switch node version :10.16.3
after switch node version is working fine..
In my case it was because of bad version of node. I've tried node 8.15.1 and it works.
On my end, after doing npm install, and attempt to run npm run watch I encountered this same issue of Error: Cannot find module 'commander'.
I did below:
// delete node_modules (can do manually) or command below
// rm -rf node_modules
npm install
And I was able to do npm run watch again.
This maybe because of corrupted packages.

npm Error “ Cannot find module 'npmlog' ”

I am running CentOS 6 and after logging in, I encounter the following error
module.js:340
throw err;
^
Error: Cannot find module 'npmlog'
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 /home/dspace/.nvm/v0.10.31/bin/npm:19:11
at Object.<anonymous> (/home/dspace/.nvm/v0.10.31/bin/npm:87:3)
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)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v0.10.31 --silent` to unset it.
I've discovered that it is a version bug and can be resolved either by upgrading the npm version or by deleting the node modules like so;
rm -rf node_modules
Then reinstalling them;
npm install
After removing the modules, npm install failed to run because of missing dependancies i.e. the modules. Now the command shows no response at all.
My node version is v0.10.48
This worked for me
Install nvm:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
Restart the terminal
Run
nvm install node
 
I had the same problem after proposed npm upgrade via npm -i -g npm. But Fedora npm/node installed via dnf has modules links to /usr/lib/node_modules/npm/node_modules.bundled/ from /usr/lib/node_modules/npm/node_modules/. I saw links were broken because usr/lib/node_modules/npm/node_modules.bundled/ disappeared. So reinstallation node,nodejs,npm via dnf/rpm solved the problem.

Getting 'invarient' not found error on creating a react native project

I am just getting started on react-native. I tried the things mentioned in the documentation.
But on running react-native init AwesomeProject.
I m getting following error.
module.js:328
throw err;
^
Error: Cannot find module 'invariant'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/aragorn/AwesomeProject/node_modules/react-native/packager/react-packager/src/node-haste/Module.js:18:19)
at Module._compile (module.js:410:26)
at loader (/Users/aragorn/AwesomeProject/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/aragorn/AwesomeProject/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
I am trying this on Mac OSX(Yosemite) with following configuration:-
nodejs - v4.3.0
npm - 2.14.12
react-native-cli- 1.3.0
Can someone please help me on this?
Look at this issue: https://github.com/facebook/react-native/issues/11327.
I tried to follow the suggestion of rogueSnake:
npm i --save-dev invariant
and worked for me
This worked for me npm i -g invariant
I resolved this by completely uninstalling node. I installed node with the web package on a Mac, so I needed to do it manually:
Manual:
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
Brew:
brew uninstall node
Reinstalled with brew:
brew install node
I received an error when doing this about the links. I tried:
brew link node
brew link --overwrite node
I got a permission error, most likely due to the above sudo rm. I am not sure if this will break anything, but it is the solution I found on other threads.
sudo chown -R $USER /usr/local
Then brew link --overwrite node worked. After reinstalling react-native react-native init was then creating projects.
I hope this helps.

bower install - Cannot find module 'q'

I'm using node v5.6.0 and bower 1.7.7 on a Mac.
I've done a npm install in my project folder which installs all the /node_modules including q.
I've also done a npm install -g q just to see if that helped.
But as soon as I run bower install (or just bower) anywhere I get
ambp:~ andreaslarsen$ bower
module.js:341
throw err;
^
Error: Cannot find module 'q'
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> (/usr/local/bin/bower:6:9)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
Any suggestions?
I had this problem recently. I reinstalled bower globally. npm install and
"npm install -g bower" solved my problem. This downloaded the required folders in to node_modules directory globally and solved problem which I faced while installing packages with bower.
Turned out I just had to restart the terminal after doing the npm install and before doing the bower install
Works fine now
I also had this problem too, I tried a new terminal which didn't fix it, so I manually installed the missing module but it refused to find others, so upon further investigation it turned out to be a botched install of bower, which hadn't installed all its libs, so rerunning
npm install
fixed it for me.

Resources