Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Error: Can't resolve 'crypto-js/aes' #1555

Closed
3 tasks done
djlauk opened this issue Jun 16, 2020 · 1 comment · Fixed by #1606
Closed
3 tasks done

Module not found: Error: Can't resolve 'crypto-js/aes' #1555

djlauk opened this issue Jun 16, 2020 · 1 comment · Fixed by #1606
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@djlauk
Copy link

djlauk commented Jun 16, 2020

Running npm install fails with an error complaining that node module crypto-js/aes cannot be found.
As a consequence, building the docker image fails as well.

Additional information

I could verify that multiple versions of crypto-js have been installed:

find node_modules -name crypto-js
node_modules/parse/node_modules/crypto-js
node_modules/parse-server/node_modules/parse/node_modules/crypto-js

I further verified, that both parse-server and Parse-SDK-JS can be built from source.

Temporary workaround

Running npm dedupe will fix the problem, but I consider this only a temporary workaround. To work on this project, following the instructions in CONTRIBUTING.md, a simple npm install should just work.


Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Dashboard!

  • You're running building version >=1.0.23 of Parse Dashboard.
    (trying to build master revision, i.e. f04d507 )

  • You're running version >=2.3.2 of Parse Server.
    (does not apply; this is a build time issue, not a runtime issue)

  • You've searched through existing issues. Chances are that your issue has been reported or resolved before.

Environment Setup

  • macOS 10.15.5 (Catalina)
  • zsh 5.7.1 (x86_64-apple-darwin19.0)
  • node 12.13.0
  • npm 6.14.5

Steps to reproduce

  • clone repository: git clone https://github.com/ParsePlatform/parse-dashboard
  • install dependencies: npm install

Logs/Trace

See attached out.log for the full output of stderr and stout combined. Here's the interesting part:

...
> [email protected] prepare /Users/lauk/coding/opensource/parse-dashboard
> webpack --config webpack/publish.config.js --progress
...
ERROR in ../node_modules/parse/lib/browser/CryptoController.js
Module not found: Error: Can't resolve 'crypto-js/aes' in '/Users/lauk/coding/opensource/parse-dashboard/node_modules/parse/lib/browser'
 @ ../node_modules/parse/lib/browser/CryptoController.js 9:6-30
 @ ../node_modules/parse/lib/browser/Parse.js
 @ ../node_modules/parse/index.js
 @ ./lib/ParseApp.js
 @ ./dashboard/Dashboard.js
 @ ./dashboard/index.js

ERROR in ../node_modules/parse/lib/browser/CryptoController.js
Module not found: Error: Can't resolve 'crypto-js/enc-utf8' in '/Users/lauk/coding/opensource/parse-dashboard/node_modules/parse/lib/browser'
 @ ../node_modules/parse/lib/browser/CryptoController.js 10:6-35
 @ ../node_modules/parse/lib/browser/Parse.js
 @ ../node_modules/parse/index.js
 @ ./lib/ParseApp.js
 @ ./dashboard/Dashboard.js
 @ ./dashboard/index.js
@mess-lelouch
Copy link
Contributor

Hitting the same issue and tried @djlauk workaround and it worked. I think the reason it worked is because npm dedupe seems to bring crypto-js dependency to the top of the node_modules directory hierarchy and then webpack can find it.

So for instance, if I instead change the webpack configuration file from

  resolve: {
    modules: [__dirname,path.join(__dirname, '../src'), path.join(__dirname, '../node_modules')]
  },

to

  resolve: {
    modules: [__dirname,path.join(__dirname, '../src'), 'node_modules']
  }

it also works as well since the current configuration seems to limit the module resolution to the parent node_modules directories and not to the children (the dependencies node_modules directories), and crypto-js dependency seems to be located in the node_modules directory of the parse dependency.

I am not suggesting we apply this change since I am not a webpack expert (started understanding it recently). I am only contributing with this observation so that someone else can decide what is the better fix for this issue.

@davimacedo davimacedo added type:bug Impaired feature or lacking behavior that is likely assumed needs investigation labels Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants