Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yarn throws Error: Cannot find module 'decamelize'

I am trying to run yarn install in the root directory of my project. Everything worked fine until I got an error in the browser console that one of the modules cannot be found. I was building the project with no errors with yarn install but in the browser, I kept getting the error that one of the modules cannot be found.

I have tried to synchronize files in the IntelliJ editor, also Invalidate caches and restart in the editor, but nothing worked, I kept building the project with yarn install with no errors but kept getting the error in the console. After that, I ran npm install, and ever since that I cannot run yarn install anymore. I have tried to reinstall node to the version 10.15.3. Ran commands npm rebuild and npm install again. For npm install I get the error:

npm WARN deprecated [email protected]: Browserslist 2 could fail on
reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: This package has been deprecated in favour of
@sinonjs/samsam
npm WARN deprecated [email protected]: This version is no
longer maintained. Please upgrade to the latest version.
npm ERR! Maximum call stack size exceeded

npm ERR! A complete log of this run can be found in:
npm ERR!    
C:\Users\MyUser\AppData\Roaming\npm-cache\_logs\2019-03-19T14_25_52_551Z-debug.log

And if I run yarn install I keep getting the error:

    $ cross-env NODE_ENV=production webpack --no-progress --colors
  --config webpack/webpack.prod.js
      internal/modules/cjs/loader.js:584
          throw err;

         ^

     Error: Cannot find module 'decamelize'

How can I fix this error?

like image 372
Leff Avatar asked Mar 19 '19 14:03

Leff


People also ask

Can not find module yarn?

Cannot find module <require-path> Ever. If you get it, it very likely means that your application is not running with the PnP resolver, meaning that your require calls won't be able to load files from your dependencies (since the node_modules needed for the regular Node resolution won't have been generated).

How do I resolve Cannot find module error using node JS?

To solve the "Cannot find module" error in Node. js, make sure to install the package from the error message if it's a third party package, e.g. npm i somePackage . If you get the error with a local module, make sure to point the node command to a file that exists.

Can not find module in node JS?

To fix Cannot find module errors, install the modules properly by running a npm install command in the appropriate directory as your project's app. js or index. js file. or delete the node_modules folder and package-lock.

Can not find module npm?

Delete the two folders npm and npm_cache in C:\Users\user\AppData\Roaming. Restart Windows and install Node. js. Run npm init or ( npm init --yes for default config)


1 Answers

Do not use two dependency management tools in the same project. You are bound to get errors. Stick to one of them. I would suggest to use yarn

  1. Delete your existing node modules folder.
  2. Delete all the lock files present eg. package-lock.json and yarn.lock file.
  3. Run fresh yarn install command. (Be sure to update yarn to the latest version to save yourself from any unknown errors).
  4. Build and test the project.
like image 91
Ashish Santikari Avatar answered Oct 03 '22 08:10

Ashish Santikari