Cannot compile Makefile using make command on Windows
I can't answer but maybe I can orient you.
First nmake
is not make. It will not work with any makefile not written specifically as an nmake makefile. And it's only available on Windows. So, best to just forget it exists.
Second, it's important to understand how make works: rules in makefiles are a combination of targets/prerequisites, and a recipe. The recipe is not in "makefile" syntax, it's a shell script (batch file). So make works in tandem with the shell, to run commands. Which shell? On POSIX systems like GNU/Linux and MacOS it's very simple: a POSIX shell; by default /bin/sh
.
On Windows systems it's much less simple: there are a lot of options. It could be cmd.exe
. It could be PowerShell. It could be a POSIX shell, that was installed by the user. Which one is chosen by default, depends on how your version of make
was compiled. That's why you see different behaviors for different "ports" of make
to Windows.
So, if you look at the makefiles you are trying to use you can see they are unquestionably written specifically for a POSIX system and expect a POSIX shell and a POSIX environment. Any attempt to use a version of make
that invokes cmd.exe
as its default shell will fail immediately with syntax errors ("" was unexpected at this time.).
OK, so you find a version of make that invokes a POSIX shell, and you don't get that error anymore.
But then you have to contend with another difference: directory separators. In Windows they use backslash. In POSIX systems, they use forward slash and backslash is an escape character (so it's not just passed through the shell untouched). If you are going to use paths in a POSIX shell, you need to make sure your paths use forward slashes else the shell will remove them as escape characters. Luckily, most Windows programs accept forward slashes as well as backslashes as directory separators (but not all: for example cmd.exe
built-in tools do not).
Then you have to contend with the Windows abomination known as drive letters. This is highly problematic for make
because to make
, the :
character is special in various places. So when make sees a line like C:/foo:C:/bar
its parser will get confused, and you get errors. Some versions of make
compiled for Windows enable a heuristic which tries to see if a path looks like a drive letter or not. Some just assume POSIX-style paths. They can also be a problem for the POSIX shell: many POSIX environments on Windows map drive letters to standard POSIX paths, so C:\foo
is written as /c/foo
or /mnt/c/foo
or something else. If you are adding paths to your makefile you need to figure out what the right mapping, if any, is and use that.
That's not even to start discussing the other differences between POSIX and Windows... there are so many.
From what you've shown above, this project was not written with any sort of portability to Windows in mind. Given the complexity of this, that's not surprising: it takes a huge amount of work. So you have these options that I can see:
- Port it yourself to be Windows-compatible
- Try to get it working inside cygwin (cygwin is intended to be a POSIX-style environment that runs on Windows)
- Try to get it working in WSL
- Install a virtual machine using VMWare, VirtualBox, etc. running a Linux distribution and build and run it there
Unfortunately I don't know much about the pros and cons of these approaches so I can't advise you as to the best course.
The route I chose, long long ago, was to get rid of Windows entirely and just use GNU/Linux. But of course that won't be possible for everyone :).
Error Cannot access 'client' before initialization while trying to make command handling
"Cannot access 'client' before initialization"
The error tells that the client
you are trying to access (in the first if
block: initialize.js:25
) should be initialised before in other words, move the lines along with the required imports before that if
block:
//..
const { Client, GatewayIntentBits } = require('discord.js');
const express = require("express");
// ..
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.commands = new Collection();
//..rest of the code
Note: the code is omitted for brevity
Edit: To prevent this systematically, you might want to use Eslint specifically no-use-before-define
. This works best in combination with Editors like VSCode along with the Eslint extension:
Error while running the command npm install
The issue is that npm
can't find the package.json
file.
Normally, this is a very simple problem that can be fixed easily.
1. Not in the directory of package.json
If you already have the package.json
file, then you need to make sure that you are in the directory in which the file is in.
To see if the file is in your directory, run the dir
command.
$ dir
If you aren't in the directory in which package.json
is in, then navigate to that directory.
2. Creation of package.json
Another issue that can occur is that you haven't yet created a package.json
file.
To do this, run the following command.
$ npm init
However, if you don't want to answer the questions from running that command, run the following.
$ npm init -y
This will initialise the package.json
file in your directory.
Edit: If you try to run npm install
, and you get the following error:
npm ERR! code ERESOLVE - unable to resolve dependency tree
That means that you have a dependency conflict. To fix this issue, run the command with the following flag.
$ npm install --legacy-peer-deps
This will resolve any incompatible packages (e.g. one package needs a lower version then what you currently have).
After you have done either of these solutions, then running the command below should work successfully.
$ npm install
Related Topics
How to Get Exact List of Collections Form Mongo Database in Shell Script
_Ldg Causes Slower Execution Time in Certain Situation
Put Graphics on The Screen Without /Dev/Fb0
Range: Bytes 0- Fails in Apache 2.2.23
How to Get Jenkins Working with Binaries from a Subfolder of The Root User
Rmpi: Cannot Use Mpi_Comm_Spawn API
Yocto: How to Install Header Files Along with Kernel Module in Sdk
Make Uses "Cc" Instead of "Arm-None-Eabi-As"
Testing - Intentionally Corrupt a .Z File Using 'Dd'
Gitlab Ce Doesn't Add a Public Key to Authorized_Keys
Get Apache Total CPU Usage in (Linux)
How to Do an Initial Setup of Slapd Olc with Ldapmodify
Maximum Number of Threads Allowed to Run
Change The Rlimit_Nproc in Linux
Ftrace: System Crash When Changing Current_Tracer from Function_Graph via Echo