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

[Windows] Can't install and run the app without errors on Windows #43

Closed
sunnymui opened this issue Feb 22, 2019 · 11 comments
Closed

[Windows] Can't install and run the app without errors on Windows #43

sunnymui opened this issue Feb 22, 2019 · 11 comments

Comments

@sunnymui
Copy link
Contributor

Tried to run and install the app on Windows 8 and it runs into several errors when doing npm i to install all the dependencies.

Some of the errors were resolved by updating my node/npm version. My npm was at 2.15.5 and node was v4.4.5 which is way behind current versions of npm 6.4 and node 10.15.1.

Easiest way for Windows people to update is to just download the latest install file from the node website and reinstall their node/npm. It'll reinstall everything to the latest version.

Still getting some errors when installing dependencies, but it does seem to get further. Looks like the next error to resolve is that it can't find Python, so I think I have to reset my Python env variable. I do have Python installed, though I did have to install it myself on Windows.

Another interesting error is a failure at the bcrypt install script with a message that it's probably not a problem with npm. Have to check it out more.

I'm attaching the complete debug log here.
2019-02-22T04_37_22_878Z-debug.log

@sunnymui
Copy link
Contributor Author

Hmm I reinstalled Python before doing anything, just in case and that actually fixed the Python error.

New critical red text error now though where it couldn't load the Visual C++ component VCBuild.exe, though it has steps to fix by installed the .NET Framework 2.0 SDK and install Microsoft Visual Studio 2005. Need to check if I have it or not

@sunnymui
Copy link
Contributor Author

sunnymui commented Feb 22, 2019

Actually, according to this, I just need to install the windows build tools so I'm trying that first.

Have to run it in PowerShell as Admin, which is different from the regular command prompt. Running npm install -g --production windows-build-tools to install.

Edit: Apparently this can take up to 8-9 hours to install. Guess I'm leaving my computer on overnight.

@sunnymui
Copy link
Contributor Author

Left the installer running for like 10-11 hours and it seems like it just froze. Hard to tell because there's no indication that it's progressing or loading or anything. From what I've read, that installer can fail and not show any error messages or notify you of anything. I shut it down anyway and restarted my computer, just in case I have some process messing something up. Haven't tried running npm install -g --production windows-build-tools again, so not sure if it would work now after a fresh reboot. I'm wondering if this npm package is different than the full Visual Studio build tools install because the gif they have of the process on their npm page looks really fast.

The other way to install build tools is to manually download the visual studio 2015 c++ build tools installer executable and then run that. Note that it can add something like 20-50gb of files to all of your drives from what I've read. It was quoting me around 4 gb which I was kind of iffy about because I have my system files partition as a separate drive that doesn't have a lot of free space.

Instead I just tried an npm start again to see if anything had changed.

Same critical red highlighted error:
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe"...(instructions telling me to install the .net 2.0 sdk, install visual studio, or add the location of the system path if it is installed)

Decided to ignore that for now and just see if there's other errors I can fix.

The other important seeming errors were warnings about needing a peer of react 15/16 for various components but none being installed. More importantly, it was saying stuff like 'react-scripts' is not recognized as an internal or external command

I figured maybe I can just manually install that, so I did:
npm install react-scripts --save

Then I tried running the app again with npm start

Surprisingly, it compiled successfully and made the page available in localhost. So I can see the actual web app now! Some kind of progress at least.

Just to summarize what I've done so far:

  1. Install latest versions of Node and NPM
  2. Install latest version of Python
  3. Ran npm install -g --production windows-build-tools and let it run for like 10 hours before deciding it probably wasn't going anywhere and ending the process.
  4. Restarting computer
  5. Tried npm i again in the disaster-response-sj repo, gettting the same error messages
  6. Manually installed react-scripts in the disaster-response-sj repo by running npm install react-scripts --save
  7. Ran npm start which successfully started a localhost with the webapp launched in my browser.

I'm not sure if everything is working right though, since I'm still missing some dependencies. I'll check with the project lead. Might be enough for front end work though.

@JMStudiosJoe
Copy link
Contributor

wow did not think would be this difficult to get running. Frontend looks to be working but still need to run the backend command nodemon --exec babel-node server.js. Then the page will load with a list of posts.

@sunnymui
Copy link
Contributor Author

sunnymui commented Feb 25, 2019

Found this helpful looking guide. I'm still reading through it, but it looks useful for the future and fairly recently published:
https://spin.atomicobject.com/2018/06/18/windows-node-js/

Haven't verified if it works, but looks like an easy process that should work. I'm kind of abbreviating the relevant looking steps here:

  1. Install Scoop - Fetches and installs packages from the web to get you running with open source tools, apparently inspired by Homebrew. In Powershell, enter iex (new-object net.webclient).downloadstring('https://get.scoop.sh') and it'll help you install
  2. Install Node.js and NVM - scoop install nodejs nvm
  3. Install sudo - To make your life easier and do things as admin inside an existing Powershell window scoop install sudo
  4. Ensure Node.js version is right for the project - The project seems to work fine with the Node.js/NPM versions I have (Node: 10.15.1 / NPM: 6.4.1), but if you need to change your version then you can use NVM commands to install and use a certain node version:
nvm install 10.15.1
nvm use 10.15.1
  1. Install Window Build Tools - Extensions are built with node-gyp which needs Python and a C compiler. These can be easily installed and configured for node-gyp by entering the following in Powershell:
    sudo npm install --global --production windows-build-tools

Edit: Also some useful info about disk space requirements for the C compiler which seems to be the important part needed for node-gyp (necessary for many extensions that need building):
https://www.quora.com/What-is-the-size-of-a-typical-C-C++-Fortran-or-Python-language-compiler-in-terms-of-physical-disk-space-How-much-space-will-it-take-if-installed-on-a-Windows-Linux-machine

On my system, it looks like Intel distributions C/C++ take up about 2G, and Fortran adds about 750M. Each Python is 500M-1G more. That said, I probably have another 1–2G of other libraries from places other than Intel that use with the system. So as always, your mileage may vary.

@sunnymui
Copy link
Contributor Author

So previously I was unable to get npm install --global --production windows-build-tools to work without it hanging + freezing. After reading through this thread, it seems like the most stable version is the 4.0.0 version (current 5.1) at least if you're having issues installing. Disk space usage ended up being around 1 gb.

So if the latest version won't install for you, try npm install --global --production [email protected] because that worked for me.

After doing that, I ran npm install again, and I got some different errors. This time, it looks like bcrypt didn't install. I manually installed that with npm install bcrypt --save.

Running npm install again completed without throwing any critical errors! However, it was still giving me several warnings that a bunch of react packages didn't detect react as a installed peer dependency. I manually installed react with npm install react --save twice for some reason it wasn't showing up when I did npm list react the first time, but installing it again made it appear.

Finally, running npm install completes successfully with only a warning about the optional dependency for the fsevents module not being supported on Windows, thus not being installed. All in all, I'd say mission accomplished finally.

@sunnymui
Copy link
Contributor Author

sunnymui commented Feb 26, 2019

If you want the TLDR on how I got the app to install without errors on Windows 8, you'll want to do the following (run PowerShell as an admin when using the console for the commands):

How to Install

  1. Install latest version of Node.js and NPM
  2. Install latest version of Python (maybe unnecessary because Python is installed as part of windows-build-tools)
  3. Install Windows Build Tools globally: npm install -g --production [email protected]
  4. Install bcrypt manually (make sure you're in the project directory): npm install bcrypt --save
  5. Install react manually (make sure you're in the project directory): npm install react --save
  6. Install app dependencies: npm i

If you encounter issues, you may have to restart your computer or run commands a second time. I'd also verify packages are actually installed by using npm list <package name to check> to see if they show up.

@sunnymui
Copy link
Contributor Author

sunnymui commented Feb 26, 2019

Previous post gets installation to work, but additional steps are necessary to get the app to run. Remember to do this in PowerShell with admin privileges:

How to Run

  1. Install Nodemon globally: npm install -g nodemon
  2. Install Babel globally: npm install -g @babel/core @babel/cli @babel/node
  3. Ask project lead for the secrets file, download it, and put it in the /config directory of the project
  4. Start the back end server: nodemon --exec babel-node server.js while in project directory
  5. Start the front end React app (open another PowerShell window): npm start

A tab should open automatically in your browser with the url http://localhost:3000/ with the UI showing and a table of disaster information.

Troubleshooting

If you encounter an error running nodemon and close your command window to try again, sometimes the node process won't be terminated and you'll get an error if you try to start nodemon again. Just go to task manager and kill any node.js processes.

If you get an error about a missing module, you might have to update the project dependencies again, especially if you haven't kept the project directory up to date. Just do an npm i again

To quit running the app, hit Ctrl + C in your PowerShell window and it'll ask you if you want to terminate the batch job. Type Y and hit enter, and it'll stop the running process. You can do that in both windows to stop the front and back end or you can just close the windows.

@sunnymui
Copy link
Contributor Author

Should probably update the readme with this info.

@JMStudiosJoe
Copy link
Contributor

JMStudiosJoe commented Mar 28, 2019 via email

@JMStudiosJoe
Copy link
Contributor

Windows users have been able to get running thank you Sunny!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants