-
Notifications
You must be signed in to change notification settings - Fork 322
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-specific build issues of utils #135
Comments
I also tried
and
but it's no different than with nothing installed as far as I can tell. At least, I'm getting the same errors. |
If I try to run node-gyp I get this message:
That led me to try node-gyp in my usual terminal (Lambda), which worked fine. But I still couldn't node-gyp configure, because I get this error with that command:
But, I found this guide nodejs/node-gyp#702 (comment) Which suggested I create a bindings.gyp file: which then let me run
which I think would have been equivalent to:
That finally let me npm install, which looking at it more closely looks like it calls node-gyp --rebuild, but I'm pretty sure it did not work for me until I did the --rebuild. So to recap, I think I needed npm global install of windows-build-tools, npm global install of node-gyp, then a bindings.gyp file somewhere (in whatever my current working directory is), then node-gyp rebuild, then npm install. To duplicate my issue, I deleted the yarn.lock and package-lock.json files as well as the node-module files, then I uninstalled the packages:
These are various packages I had installed with testing, though socket-io should have been socket.io if I was paying more attention. This left me with an empty npm global list, double-checking installs with
So I repeated the same thing with yarn:
I even went and searched Windows (Win+R for Run) for Uninstall Python, clicked that, and removed Python 2.7 -- I had previously removed Python 3.8 from the Windows Store. I furthermore searched Windows (Win+R for Run) for Visual Studio Installer, clicked that, clicked More, under Installed -> Visual Studio Build Tools 2017, clicked Uninstall, clicked OK. I waited a long time I should be really starting fresh, to document the fix steps for a new user. I start reproducing my steps here Then I tried to install them fresh, using my regular terminal (lambda, with git for Windows installed, and my current version of node) as much as I could. I then ran these npm commands: Step 1: From an Administrative Powershell (Windows key + X, Windows Powershell Admin):
Resulting in success:
Steps 2-4: Then from my regular terminal (Lambda with Git for Windows) -- because I knew Administrative Powershell would balk at me running node-gyp, as that is written in Python, and I would have to change the scripts access restriction to run from that terminal. I navigated navigated my terminal to =open the /screeps-typescript-starter/ directory, then I made the bindings.gyp file in that current directory, using the sample text from above. Then I ran these npm commands:
But it didn't quite work, as I will explain below: Note that node-gyp rebuild by itself did not work, I got this error:
I tried updating the binding.gyp file to reference an existing file (binding.sln) I found in the repository:
That let me run
and then if I changed binding.gyp back to the other way it seemed to work fine:
Now I could run
Albeit with this error message:
But I changed it back to the first way just to be consistent, with the binding.sln file. Steps 1-4:
A quick note regarding the previous question I posed about needing "node-gyp configure" and "node-gyp build" -- "npm node-gyp rebuild" did seem to work the same as build and configure, based on it ending with the message "ok" at least. This makes sense based on the console documentation message for node-gyp that lists But npm install still did not work I deleted the lock files and global installs for npm again and then tried it with yarn: The yarn instructions are similar but would use yarn terminology.
Then from a regular terminal: (Lambda with Git for Windows):
Still no dice -- it didn't work. I tried this solution: nodejs/node-gyp#702 (comment)
But it still didn't work. So, somehow, I got it working there briefly, but I was unable to reproduce my fix when I tried to duplicate the issue. |
Other random things I tried:
I found this note: nodejs/node-gyp#2025 (comment)
|
A Solution?I suppose in the end this ties into my choice to not open node version manager (nvm) and downgrade to the recommended Node 10.x But, I found this guide , which recommends this command:
https://spin.atomicobject.com/2019/03/27/node-gyp-windows/ Because of this note
Followed by this command:
I think I may have entered this before but not documented it, which is why I could not reproduce it And then another command:
And I found this command in the comments:
With this information in hand, I now manually uninstalled the 2017 Windows Build Tools (as documented, using the Visual Studio Installer), and all global npm packages. Then I started fresh in a new Administrative Windows Powershell:
At this point, npm install still failed. So I tried:
I then tried
and
which gave me the error:
|
I also tried
|
So finally, I installed nvm for Windows using the setup for node version manager for Windows from here: In a Administrative Windows Powershell, I did
Then I had success with:
To make sure it worked, I deleted the node-modules folder and the package-lock.json file, as well, and tried npm install again, but got this error:
That crashed, apparently because I was missing the npm package rollup (unmet peer dependency), so I did this and got it to work:
Note that all my global npm packages (windows-build-tools and node-gyp) disappeared with nvm, which only gave me the single global package installed of [email protected] corresponding with my node version 10.21.11 -- I thought I should mention. Digging further, I did
which returned
so I did
That resulted in:
So I did:
Which gave me:
I think that means it's fully installed and working (thanks to downgrading to Node 10 with nvm) Updated pull requestI went ahead and updated my pull request #136 -- I see now that Node 10 is in fact the dependency, although apparently the support for that will stop in April 2021 or whatever I saw in that other post. |
Oh, I also didn't need the binding.gyp file |
I think the easiest solution is to use Yarn instead of npm. I use Node 12 and Yarn. I do get that compilation error, but since it's from an optional dependency, Yarn considers it a warning and everything works. And I get to use Node 12 features, which I need for my mocking functions. |
Thanks @eduter , you're right. I think either npm or yarn work, just with those warnings, which I was trying to eliminate. The warning messages were less aggressive in yarn, for what it's worth. Rolling back to Node 10 let everything compile without warnings for me on Windows 10. As per #136 it's a good point that Screeps itself is using Node 10, so maybe node version manager is still a good solution if you don't need Node 12 features 😄 I'm a little irked that I got it fixed at one point with Node 12 on Windows but then couldn't reproduce it. 🤷 Have a good one! |
@eduter For what it's worth, trying today with nvm (10.20.1) from scratch, yarn (v1.22.4) works fine to compile both those dependencies previously mentioned. But when I go to add screeps with yarn add screeps, it bails:
It's the same with
So I followed this guide https://screeps.com/forum/topic/477/screeps-server-on-windows specifically:
Again, I was still using Node v10 via nvm. Unfortunately, that barfed some errors while compiling. Thinking it was node-gyp again, I stuck with the administrative powershell and did:
And set [A] Yes to All for changing the execution policy. Then when I entered node-gyp it seemed to work, so I tried npm install -g screeps again, but it bailed because files were existing. So I tried npm install -g screeps --force That appeared to succeed, albeit with many warnings including some node-gyp stuff:
So going back to the screeps-typescript-starter working directory, I started over by doing yarn cache clean:
Just to be safe, I did the same with npm to clean the cache:
Followed by npm install -- which succeeded as previously:
Followed by npm install screeps-server-mockup (now that the @screeps dependency was installed globally under my versioned Node 10), which finally succeeded!
Yay! 😄 Integration testing!From here, I could finally do npm run test with success:
Hallelujah 🌮 🎉 🥳 🦖 How to install screeps-server-mockup on Windows 10These are my steps from the beginning, using an Administrative Powershell (Windows+X, Windows PowerShell (Admin):
I selected [A] for Yes to All about the Windows Execution Policy change, which was necessary to run node-gyp in the Administrative PowerShell. My environment using nvm (Node Version Manager) is Windows 10 and Node v10.20.1 x64 bit. That let me run the following inside the screeps-typescript-starter project:
The integration tests that depend on the screeps server succeed! To recap, here are my global npm modules: (Windows 10 running Node 10.20.1, 64-bit via nvm)
And my nvm list for confirmation:
I'm not 100% sure how I would get the windows-build-tools global on yarn, so I did switch back to npm. I guess it doesn't make much difference, though. (For what it's worth, yarn test is the same as npm test, since yarn test calls what's in the package.json file, which is npm run test-unit && npm run-test-integration... The only difference appears to be that yarn test tells me the whole process took "Done in 17.41s" but I get no such message with npm.) |
I had some Windows quirks, where two packages wouldn't get built.
(Maybe I should have just known better, because of the node-gyp dependency.)
then I had to open an Administrative PowerShell with Windows + X, Powershell (Admin), where I had to run
Or equivalently with yarn:
yarn global add --production windows-build-tools --vs2017
It looks like that command automatically downloaded Python (2.7)
I had tried installing Python separately, but I think that doesn't matter because the npm command appears to install Python 2.7.
I thought I would need to install it separately, because I got a few errors about Python not being installed, so I had to install it from the Windows Store at https://www.microsoft.com/en-us/p/python-38/9mssztt1n39l
However, it does look like I had to run the VS Build Tools file it downloaded separately (
C:\Users\${username}\.windows-build-tools\vs_BuildTools.exe
) in order to get the npm command to work -- it looks like the version control was slightly off for me (5.1.7 vs 5.2.2).Following that, I had to add that file (
C:\Users\${username}\.windows-build-tools\vs_BuildTools.exe
) to the antivirus software exclusion list (Windows Defender is accessible from Settings -> search Defender to reach Windows Security, click Virus & threat protection, click Manage settings under Virus & threat protection settings, scroll down to Exclusions, click Add an exclusion, click File, paste the Path, click Open, then run the npm install --global --production windows-build-tools --vs2017 command again.)The exact path for the vs_BuildTools.exe file name is at least referenced in the Administrative Powershell output -- even if it fails. That made it was pretty easy to copy & paste to run (by executing in the Administrative Powershell) and to add to the exclusions list.
Doing all this...
Doing all this left me with two ongoing installations that fail:
with this same output
And the results appeared the same in both npm and yarn, as you would expect.
Obviously, these are optional dependencies, but I couldn't figure out how to get them built.
Any ideas?
The text was updated successfully, but these errors were encountered: