Yarn throws Error: Cannot find module 'decamelize'

时间:2019-03-19 14:39:36

标签: node.js npm webpack yarnpkg

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 error:

npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools. npm WARN deprecated samsam@1.3.0: This package has been deprecated in favour of @sinonjs/samsam npm WARN deprecated hoek@5.0.4: 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?

1 个答案:

答案 0 :(得分:1)

请勿在同一项目中使用两个依赖项管理工具。您一定会出错。坚持其中之一。我建议使用纱线

  1. 删除现有的节点模块文件夹。
  2. 删除存在的所有锁定文件,例如。 package-lock.json和yarn.lock文件。
  3. 运行新鲜纱线安装命令。 (请确保将yarn更新到最新版本,以免出现任何未知错误)。
  4. 构建和测试项目。