awslabs / aws-api-gateway-developer-portal

A Serverless Developer Portal for easily publishing and cataloging APIs
Apache License 2.0
928 stars 402 forks source link

'Cannot find module' errors when running 'node run install release' #496

Closed jTendeck closed 3 years ago

jTendeck commented 3 years ago

Hi there! I am just trying to deploy the developer portal using method 3 (deploy using the development scripts) but I am running into an issue.

I was able to successfully follow all of the prerequisite steps and I have successfully deployed the portal to AWS. I start running into issues when following the steps outlined in the BUILDING.md file.

I start running into issues when I make it to step 5: Run node run install release.

It appears the install phase mostly runs without a hitch, but I encounter an error when it enters the build stage.

Here is the error I see:

Task completed: install
dev-portal/ task for build started
[ run cmd ]  npm run build --

> dev-portal@4.1.0 build
> react-scripts build

Creating an optimized production build...
Failed to compile.

./src/index.js
Cannot find module: 'react-router-dom'. Make sure this package is installed.

You can install this package by running: npm install react-router-dom.

dev-portal/ task for build completed (code: 1)
Task errored: build
Task errored: release

I should also mention before this happened, I also saw an error saying Cannot find module: 'react-scripts'. which I fixed by running npm i react-scripts

I tried running npm i react-router-dom which leads to a cannot find module for semantic-ui-css/semantic.css... when I try to install that I see: error code 128: command failed. ERROR: Repository not found. Fatal: Could not read from remote repository.. and at this point I’m not sure what to do.

To try and remedy this I tried a few things, like making sure Git/Node/AWS CLI/SAM CLI are all the latest version, deleting node_modules in both the project root directory and dev-portal directory and installing fresh dependencies using npm install, running sudo node run install release but nothing seems to work.

Any advice on how to resolve this issue? I am not really sure where to go from here.

When running node run install release I also see the following error before it gets to cannot find module errors mentioned above:

Execution for root completed
Execution for dev-portal started
[ run cmd ]  npm install
npm ERR! code 128
npm ERR! command failed
npm ERR! command git --no-replace-objects clone -b apigw-fork-v4 ssh://git@github.com/awslabs/swagger-ui.git /root/.npm/_cacache/tmp/git-clone-e73a5428 --recurse-submodules --depth=1
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-e73a5428': Permission denied

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-08-07T21_53_30_766Z-debug.log
Execution for dev-portal completed (code: 128)

I am running:

Let me know if you require any more information. Thanks for any help!

ghost commented 3 years ago

Try this:

  1. Back up your dev-portal/deployer.config.js to somewhere outside the repo
  2. Delete and re-clone the repo
  3. Restore your dev-portal/deployer.config.js from that backup
  4. Change to the dev-portal directory and run npm install
    • The node run install simply runs npm install in each relevant package directory within the repo - it's not particularly magical.

Once you do that, check if dev-portal/node_modules/react-router-dom exists. If it does, you can navigate back to the root and just run node run install release (the extra install won't do much within dev-portal as you already did that previously). If it doesn't, then I'd recommend asking either in https://github.community/c/software-development/47, https://github.com/npm/cli/issues, or https://stackoverflow.com/questions/tagged/npm as appropriate as it's a permissions issue caused by Git and/or npm and you'd have to sort out which one's causing it. (I couldn't reproduce it locally.)

Here's a couple related SO questions for additional reference:

The offending repo you're having issues with (https://github.com/awslabs/swagger-ui) is itself public, so that's not a concern.

jTendeck commented 3 years ago

Thanks for your response!

In the end I used a different version of npm - 6.14.8. Everything seems works as expected with that version.