简体   繁体   中英

Can't run custom module on AWS/nodejs. Exits with error: Cannot find module

I want to switch to a fork of the parse-server module on AWS elastic beanstalk, but no matter what I try I get this error when the server tries to start up:

Error: Cannot find module 'parse-server'
    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> (/var/app/current/index.js:64:21)
    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)

The original module works without a problem:

  • in package.json:
     "parse-server": "3.10.0",
  • but neither of these ones do work:
     "parse-server": "https://github.com/andrewking0207/parse-server.git#appleAuth",
     "parse-server": "andrewking0207/parse-server.git#appleAuth",

when I ssh into to the ec2 instance the module is installed inside node-modules. What am I missing here?? Locally on my machine everything runs fine.

You can not install directly from a GitHub fork because it does not have the lib folder which is created during the build process. There is a workaround though:

1 - Clone your fork to your machine 2 - Remove the lib folder from the .gitignore file 3 - Run npm install 4 - Run npm build 5 - Commit the changes to your local git 6 - Push the commit to your remote fort branch at GitHub

Then you can try to install it again and it should work. I just wanted to make clear that it is a workaround and not the recommended way to use Parse Server. If you explain what you want to achieve by using your own fork, I can try to advice about the "right" way to be done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM