I have tried to open my existing Amplify project on two separate computers (beyond the original used to create the project) and both times it has not worked. I follow the getting started steps, then open the existing project and attempt to run it with serve or publish and it fails with a missing module.
Steps to reproduce the behaviour:
On a new computer, install Node and NPM
Install and configure amplify CLI
Clone existing Amplify project
run command amplify serve or amplify publish
Fails with error of missing module, amplify-frontend-javascript
Identical behaviour on existing install of Windows 10 Pro and a fresh install of Linux Mint 19. The project was originally created on MacOS 10.13 High Sierra.
The error specifically is:
Cannot find module '/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation'
C:\UsersAlexAppData\Roamingnpm\node_modules\@aws-amplify\cli\node_modules\gluegun\buildindex.js:13
throw up;
^
Error: Cannot find module '/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-frontend-javascript'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Command.run (C:\UsersAlexAppData\Roamingnpm\node_modules\@aws-amplify\cli\src\commands\run.js:8:7)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
Run the ‘amplify configure project’ command to setup the Amplify project on a different machine.
I just tried this, it went through the steps correctly but still cannot find the module. Am I supposed to install the module manually?
@Exitialis1 For the time being what you could do is modify the .config/project-config.json's awscloudformation key manually to "amplify-provider-awscloudformation" instead of the absolute path - /usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation.
The amplify configure project
command should have taken care of the paths ideally.
@kaustavghosh06 When I looked on the windows machine, after running amplify configure project again just in case, the path to amplify-provider-cloudfront was correct, but the path to amplify-frontend-javascript was incorrect. I tried updating it to a correct absolute path and got the below error.
frontend start command execution error
{ Error: spawn npm ENOENT
at _errnoException (util.js:992:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn npm',
path: 'npm',
spawnargs: [ 'run-script', 'start' ] }
Then I removed the paths from both individually, and at the same time and still got the same error.
which command got you this error?
Seems like the issue is tied to the "npm run-script start" command which is running on your project.
@kaustavghosh06 Sorry, amplify serve and amplify publish both caused this error, from watching their outputs I gather that those scripts are what is calling npm run-script start. If it helps I just followed the guide on building a react app and used create-react-app when getting started as detailed here: https://aws-amplify.github.io/amplify-js/media/react_guide.
I too was having this error. The recommended steps did not work. If you want me to create another test case please let me know. I have a couple of laptops with similar configurations on them.
Is there any chance of at least a workaround to this problem? This bug is a very good reason to not continue using Amplify.
@Exitialis1 what’s the frontend framework that you’re using? In your main package.json do you have a run-script object with the start command?
@kaustavghosh06 my project was started create-react-app. It does yes: "start": "react-scripts start",
@Exitialis1 can you try manually running npm run-script start from the root of your project and see if that works?
@kaustavghosh06 "npm run start" works but it fails to compile with this error: ./node_modules/aws-amplify-react/dist/Analytics/trackLifecycle.js
Module not found: Can't resolve '@aws-amplify/analytics' in '/home/alex/Git/capt-america/node_modules/aws-amplify-react/dist/Analytics'
Edit: Sorry there is a start script on the original machine and it works fine, I had the wrong project open.
I believe the root cause for the errors on the “amplify serve” and “amplify publish” commands were the error you mentioned in the comment above. The commands didn’t expose the actual error whcih I believe was confusing. We’ll work on exposing the actual error message as a part of the serve and publish commands.
@powerful223 @mlabieniec Could you help out here in the meanwhile in roof causing the JS lib error tied to analytics mentioned in the above comment?
@kaustavghosh06 I came across this bug as I have a similar issue. I was unable to push graphql schema changes between two different machines I'm using. I noticed that amplify configure project
changes a few files/settings. Mostly timestamps but one i did notice is the projectPath
in projectPath.json. I'm going to mirror paths on the two machines for now but I was wondering if there are files that should be .gitignore'd from the repo?
Edit: found an answer here: https://github.com/aws-amplify/amplify-js/issues/1635#issuecomment-427169420
Most helpful comment
Run the ‘amplify configure project’ command to setup the Amplify project on a different machine.