Giter Club home page Giter Club logo

driver's Introduction

npm version

logo

Screeps is a MMO RTS sandbox game for programmers, wherein the core mechanic is programming your units AI. You control your colony by writing JavaScript which operate 24/7 in the single persistent world filled by other players on par with you.

This project is a distributed, standalone game server that allows you to launch your own game world on a local computer or dedicated server on the Internet.

Server launch

The server consists of multiple parallel processes linked to each other. There is a separate launcher process to launch them correctly, and these launchers have various versions for different purposes.

GUI launcher. This is the easiest way to launch the server. It comes with the standard package of the Steam version of the game. You launch the game via the server's executable file that shows the GUI with logs of all started processes and the CLI interface to control the server.

Console launcher. You can also launch the server without the GUI using the command line:

npm install screeps
npx screeps init
npx screeps start

Prerequisites:

You will be prompted for your Steam Web API key, you can obtain it on this page.

Your own launcher. The launchers are intended to launch other server's processes and give them correct environment variables. You can launch those processes your own way (for example, via upstart/systemd, for distributing them across different machines, or setting up an automated testing framework). Please refer to the file launcher/lib/start.js for the list of environment variables that each process needs.

Storage

The default built-in storage is based on LokiJS library which allows to embed it in pure JavaScript environments like the Steam game client. It stores all data in the db.json file. However, you can manually replace the storage engine with another community solution to improve performance.

See this step-by-step guide which explains how to install a standalone private server on Ubuntu using MongoDB and Redis as a storage.

Connect to server

You can connect to your private server using the Steam game client. Click "Change server" and enter your server credentials:

client

Launch options

If you use a stock launcher (either desktop or console), the file .screepsrc in the current catalog stores launch configuration options. You can specify them directly when you launch the server using the console command start.

> npx screeps start --help	
Usage: start [options]	
Start all processes. Launch options can be configured from command line or using the .screepsrc file in the same folder.	
Options:

    -h, --help               output usage information
    --db <path>              The path to the database file.
    --logdir <path>          The path to directory where logs will be created.
    --modfile <path>          The path to JSON file with the list of custom mods to load. Defaults to mods.json.
    --assetdir <path>        The path to directory where static assets are located.
    --port <port>            The port number on which the game server should listen. Defaults to 21025.
    --host <host>            The hostname on which the game server should listen. Defaults to 0.0.0.0.
    --password <password>    The server password which should be provided on user sign in. Default is empty.
    --cli_port <port>        The port number on which the CLI server should listen. Defaults to port+1.
    --cli_host <host>        The hostname on which the CLI server should listen. Defaults to 127.0.0.1.
    --runners_cnt <num>      The number of parallel runner worker processes to launch. Don't set this option greater than the number of your physical CPU cores. Default is 2.
    --processors_cnt <num>   The number of parallel processor worker processes to launch. Don't set this option greater than the number of your physical CPU cores. Default is 2.
    --steam_api_key <key>    If you launch the server without running the local Steam client, then the Steam Web API key is required for authenticating users. It can be obtained on this page: http://steamcommunity.com/dev/apikey

Modules

The server consists of 6 separate modules: launcher, storage, backend, engine, driver,common. They may be in the node_modules of any catalog according to the npm rules. Each module has its own code base and GitHub repository, while the engine module is shared between the official and standalone servers and other modules are developed specifically for the standalone server.

Each module is intended for its own strict purpose:

  • launcher launches the rest of the processes, and it includes the server control GUI.

  • storage contains a LokiJS-based database, a key-value storage, and a Pub/Sub mechanism. The rest of the processes connect to storage to exchange data.

  • backend contains an HTTP server accessed by clients and a CLI server for administration.

  • engine is the game core. It executes game scripts and interacts with game world objects.

  • driver is a link between the environment-independent engine (that is shared for the official server, standalone server, and in-browser simulation) and the immediate environment that hosts the game engine. You can replace this module with your own one, if you wish to use another method of storing and handling data.

  • common is a shared code base with useful utilities.

modules

Authentication

The server does not have any user authentication mechanism of its own. Instead, Steam is employed for this purpose, and the server has two mechanisms that work in parallel to achieve this:

  • Native authentication via the local Steam client on your machine. This is the easiest and handiest method that does not require any setting up and works automatically when launched via Steam.

  • If you want to launch your server on a machine without a Steam client installed, you will have to set up authentication via the Steam Web API. To do this, register a new Steam API Key on this page and set it as the steam_api_key option at the server launch.

Command Line Interface (CLI)

The running server process provides administrative access using a separate port (21026 by default) which allows executing inner server commands using batch commands. It is accessible through the Steam GUI or using this console command:

npx screeps cli

The CLI server contains a JavaScript virtual machine allowing to run any valid JS code and work with inner server functions. They allow changing game objects and call procedures, including those added by you. Some examples of such commands:

// Add an NPC bot to the map
bots.spawn('simplebot', 'W3N1');

// Send a server message to all connected users
system.sendServerMessage("OHAI");

// Generate a new room and add it to the world
map.generateRoom("E0N3", {sources: 4, terrainType: 2});

// View user's data by his username
storage.db['users'].findOne({username: "User"});

// Show all creeps in a room
storage.db['rooms.objects'].find({$and: [{room: 'W1N1'}, {type: 'creep'}]});

// Remove an object by its id
storage.db['rooms.objects'].removeWhere({_id: "abcdef"});

Type help() to get a detailed help for all available objects.

Mods

The game server is written in such a way that you can redefine and configure many aspects of its work. Do not modify server code directly! This will block you from updating with new releases, and the official Steam client of other players will stop connecting to your server. Rather than editing the server's source, create mods.

Mods are simple js files listed in the mods.json (the default folder can be changed through the modfile launch option). Each file must be a Node.js module that exports a single function that receives as an argument a config object:

module.exports = function (config) {

}

Each server process will automatically include all the mods at launch and pass the object config to them with properties corresponding to the type of the launched process. If the server consists of 10 processes, then each mod file will be requested 10 times, each time with a different type of config.

All config child objects are EventEmitter instances that you can listen for game engine events. They also contain some properties that can be simple numeral or string configuration parameters as well as functions that you can redefine thus changing server behavior. Their number will increase with time. We have not prepared documentation for all the available properties yet, but the folder example-mods offers a few simple examples of what you can change by mods. We also recommend to investigate the config object of various processes on your own to find out what is possible.

Installing mods

There are three methods to install a mod to your server:

  • Edit mods.json manually and add a new entry to the array in it.
  • If the mod is published to the NPM repository, you can run npm install my-screeps-mod in your server folder, and it will be added automatically. (CAUTION: There is a bug in some npm 5.x versions which prevents auto install hooks from running.) The mod's package.json should contain "screeps_mod":true parameter in this case:
{
  "name": "my-screeps-mod",
  "version": "1.0.0",
  "main": "my-screeps-mod.js",
  "screeps_mod": true
}
  • Using the Steam Workshop.

NPC bots

You can create autonomous NPC bot players on your private server. They work as regular players, but you can specify their AI scripts in bots option at your mods.json file. Initially there is one AI loaded into your server, called simplebot, but you can always add more, and share with other players.

Use the following CLI commands to control bot players on your server:

> help(bots);
Available methods:
 - bots.spawn(botAiName, roomName, [opts]) - Create a new NPC player with bot AI scripts, and spawn it to the specified room. 'opts' is an object with the following optional pr
operties:
    * name - the name of a bot player, default is randomly generated
    * cpu - the CPU limit of a bot user, default is 100
    * gcl - the Global Control Level of a bot user, default is 1
    * x - the X position of the spawn in the room, default is random
    * y - the Y position of the spawn in the room, default is random
 - bots.reload(botAiName) - Reload scripts for the specified bot AI.
 - bots.removeUser(username) - Delete the specified bot player and all its game objects.
Bot AIs:
 - simplebot [D:\SteamLibrary\steamapps\common\Screeps\server\@screeps\simplebot\src]

If you want to publish your bot AI to the NPM repository, set main.js as the main entry in your package.json, and add screeps_bot:true parameter:

{
  "name": "my-screeps-bot",
  "version": "1.0.0",
  "main": "src/main.js",  
  "screeps_bot": true
}

driver's People

Contributors

alinanova21 avatar artch avatar laverdet avatar o4kapuk avatar ricochet1k avatar sheeo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

driver's Issues

isolated-vm outdated

It seems that isolated-vm required (2.0.1) is too old (the last version is 3.3.7), causing build error on Nodejs LTS 14

driver.getAllRooms was removed in 5.1.0

This is more informational than a complaint, but it seems that driver.getAllRooms was removed from the API in the latest minor release 5.1.0. see: 18bcfce

This ended up breaking @screepers/screeps-server-mockup because we were using this function to fetch all of the rooms of interest. I did not expect a breaking change such as a reduction in API surface to come from a minor release update.

Luckily, it was a pretty simple fix to get updated. Just wanted to give you guys insight into compatibility issues which can arise.

Feel free to ACK and close this once it has been noted

[Beta.8] publicSegments breaks user code

In the current ivm betas there is a bug breaking publicSegment lists, it is attempting to run join(',') twice, resulting in an error for the second attempt.

env.set(env.keys.PUBLIC_MEMORY_SEGMENTS+userData.user._id, runResult.publicSegments.join(','));

outMessage.publicSegments = publicSegments.join(',');

I can make a PR if desired, which of the two lines needs to be edited? Currently, on S+ I've just removed .join(',') from the make.js line, thus solving it.

Recommended shutdown method?

The driver doesn't seem to export a disconnect or shutdown method. After shutting down the processes I've spawned for other modules, I get the following error non-stop until the process that called connect() on the driver is stopped

Connecting to storage
Storage connection lost { Error: connect ECONNREFUSED 127.0.0.1:21025
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 21025 }
Connecting to storage
Storage connection lost { Error: connect ECONNREFUSED 127.0.0.1:21025
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 21025 }
Connecting to storage
Storage connection lost { Error: connect ECONNREFUSED 127.0.0.1:21025
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 21025 }

It looks like that is the result of a retry that exists in the common storage _connect() method that has an unending connect retry here https://github.com/screeps/common/blob/master/lib/storage.js#L150

Does a way exist to shutdown the driver so that these continuous attempts at connecting to killed processes will stop? And if not, is there a recommended way of starting the driver to prevent this kind of output?

Update to Python 3

On the main page of the screeps server it states only Python 2 is supported. Meanwhile there have been some updates to node-gyp and now supports Python 3. From version 5.0.4 I believe.

I would like to add support for the newer node-gyp version. Installing node-gyp using Python 3.10.8 was succesfull.

However I am not completely familiar with the npm enviroment. So when testing the driver module this was the error message.

code 1
npm ERR! path /Users/hayer/driver/node_modules/isolated-vm
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild --release -j 4
npm ERR! CXX(target) Release/obj.target/nortti/src/external_copy_nortti.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info find Python using Python version 3.10.8 found at "/Users/hayer/.pyenv/versions/3.10.8/bin/python3"
npm ERR! gyp info spawn /Users/hayer/.pyenv/versions/3.10.8/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/hayer/driver/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/hayer/driver/node_modules/isolated-vm/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/hayer/driver/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/hayer/Library/Caches/node-gyp/14.21.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/hayer/Library/Caches/node-gyp/14.21.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/hayer/driver/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/hayer/Library/Caches/node-gyp/14.21.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/hayer/driver/node_modules/isolated-vm',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build', '--jobs', 4 ]
npm ERR! In file included from ../src/external_copy_nortti.cc:1:
npm ERR! In file included from ../src/external_copy.h:10:
npm ERR! ../src/isolate/util.h:28:75: error: no viable conversion from 'const v8::Local<v8::Context>' to 'v8::Isolate *'
npm ERR!         return Unmaybe(Unmaybe(options->Get(context, v8_string(key)))->ToBoolean(context))->IsTrue();
npm ERR!                                                                                  ^~~~~~~
npm ERR! /Users/hayer/Library/Caches/node-gyp/14.21.1/include/node/v8.h:2848:37: note: passing argument to parameter 'isolate' here
npm ERR!   Local<Boolean> ToBoolean(Isolate* isolate) const;
npm ERR!                                     ^
npm ERR! In file included from ../src/external_copy_nortti.cc:1:
npm ERR! In file included from ../src/external_copy.h:10:
npm ERR! ../src/isolate/util.h:28:9: error: no matching function for call to 'Unmaybe'
npm ERR!         return Unmaybe(Unmaybe(options->Get(context, v8_string(key)))->ToBoolean(context))->IsTrue();
npm ERR!                ^~~~~~~
npm ERR! ../src/isolate/util.h:10:36: note: candidate template ignored: could not match 'MaybeLocal' against 'Local'
npm ERR! template <typename T> v8::Local<T> Unmaybe(v8::MaybeLocal<T> handle);
npm ERR!                                    ^
npm ERR! ../src/isolate/util.h:11:25: note: candidate template ignored: could not match 'Maybe' against 'Local'
npm ERR! template <typename T> T Unmaybe(v8::Maybe<T> handle);
npm ERR!                         ^
npm ERR! 2 errors generated.
npm ERR! make: *** [Release/obj.target/nortti/src/external_copy_nortti.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/hayer/driver/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
npm ERR! gyp ERR! System Darwin 22.3.0
npm ERR! gyp ERR! command "/Users/hayer/.local/share/nvm/v14.21.1/bin/node" "/Users/hayer/driver/node_modules/.bin/node-gyp" "rebuild" "--release" "-j" "4"
npm ERR! gyp ERR! cwd /Users/hayer/driver/node_modules/isolated-vm
npm ERR! gyp ERR! node -v v14.21.1
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok

PTR: Promises are back

Promises were disabled in #6 to prevent timeout skipping, with PTR on Node 7.9 Promises can be restored and used via the new async/await feature as seen below, this effectively readds the Promise class to global.

    let promise = async function(){ return '' }
    global.Promise = promise().constructor

HeuristicWeight should be allowed to be higher than 9

let heuristicWeight = Math.min(9, Math.max(1, options.heuristicWeight || 1.2));

There is no reason for the heuristicWeight to be limited to only 9.
Actually this has lead to some unexpected results:
https://screeps.com/forum/topic/2768/pathfinder-using-heuristicweight-to-implement-fractional-costs

I propose to remove that upper limit or choose a very high limit. The user that sets a heuristicWeight that high knows what (s)he's doing and would just be surprised of the high cpu costs that happen because it's actually capped to 9 (undocumented as well).

shardName should not be blank

shardName: ''

This should match the value in Game.shards.name for consistency, and remain moddable. Even better if we could set it via config.engine like other options ;)
Could just add shardName: os.hostname() to the config object at the top, and reference that in both the Game.shards building and this.

Time sometimes goes backwards for a moment

My hypothesis is that this read is not atomic, the high bits are read, then the timer rolls over to a new high bit, the low bits have gone from max to min value when they roll over, and now the low bits are read.

Before the call to getUsed the timer may have been

0xFAFF

Now it's

0xFB00

The JavaScript code reads

0xFA00

(Numbers not to scale)

return isolate.cpuTime[0] * 1e3 + isolate.cpuTime[1] / 1e6;

I believe if cpuTime is copied to a local value first, and then destructed [0], [1]. Time will no longer go backwards and getUsed will never be negative

Cheers.

Missing STD <limits> Headers for GCC 11+

The Problem

It appears that with GCC11 some headers with libstdc must be explicitly included. Namely, <limits>

Reference: Porting to GCC11 - Header Dependency Changes

Versions Replicated On

  • Screeps 3.4.0
  • Python 2.7
  • GCC 11.2.1
  • Node 16.13.0
  • node-gyp 3.8.0
  • OS: Fedora 35

Steps to Replicate

npm init
npm i screeps

Resulting Output

npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Scroll issue in Chrome fixed in version 1.0.5
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm ERR! code 1
npm ERR! path /mnt/kube-storage/Screeps/node_modules/@screeps/driver
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild -C native && webpack
npm ERR! make: Entering directory '/mnt/kube-storage/Screeps/node_modules/@screeps/driver/native/build'
npm ERR!   CXX(target) Release/obj.target/native/src/main.o
npm ERR! make: Leaving directory '/mnt/kube-storage/Screeps/node_modules/@screeps/driver/native/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info chdir native
npm ERR! (node:3226283) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! gyp info spawn /usr/bin/python2
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/mnt/kube-storage/Screeps/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/mnt/kube-storage/Screeps/node_modules/@screeps/driver/native/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/mnt/kube-storage/Screeps/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.node-gyp/16.13.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.node-gyp/16.13.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/mnt/kube-storage/Screeps/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.node-gyp/16.13.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/mnt/kube-storage/Screeps/node_modules/@screeps/driver/native',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/main.cc:5:
npm ERR! ../src/pf.h:16:28: error: ‘numeric_limits’ is not a member of ‘std’
npm ERR!    16 |         static_assert(std::numeric_limits<pos_index_t>::max() > 2500 * k_max_rooms, "pos_index_t is too small");
npm ERR!       |                            ^~~~~~~~~~~~~~
npm ERR! ../src/pf.h:16:54: error: expected primary-expression before ‘>’ token
npm ERR!    16 |         static_assert(std::numeric_limits<pos_index_t>::max() > 2500 * k_max_rooms, "pos_index_t is too small");
npm ERR!       |                                                      ^
npm ERR! ../src/pf.h:16:57: error: ‘::max’ has not been declared; did you mean ‘std::max’?
npm ERR!    16 |         static_assert(std::numeric_limits<pos_index_t>::max() > 2500 * k_max_rooms, "pos_index_t is too small");
npm ERR!       |                                                         ^~~
npm ERR!       |                                                         std::max
npm ERR! In file included from /usr/include/c++/11/algorithm:62,
npm ERR!                  from ../../../../nan/nan.h:61,
npm ERR!                  from ../src/main.cc:2:
npm ERR! /usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
npm ERR!  3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
npm ERR!       |     ^~~
npm ERR! In file included from ../src/main.cc:5:
npm ERR! ../src/pf.h: In member function ‘void screeps::open_closed_t<capacity>::clear()’:
npm ERR! ../src/pf.h:186:42: error: ‘numeric_limits’ is not a member of ‘std’
npm ERR!   186 |                                 if (std::numeric_limits<marker_t>::max() - 2 <= marker) {
npm ERR!       |                                          ^~~~~~~~~~~~~~
npm ERR! ../src/pf.h:186:65: error: expected primary-expression before ‘>’ token
npm ERR!   186 |                                 if (std::numeric_limits<marker_t>::max() - 2 <= marker) {
npm ERR!       |                                                                 ^
npm ERR! ../src/pf.h:186:68: error: ‘::max’ has not been declared; did you mean ‘std::max’?

npm ERR!   186 |                                 if (std::numeric_limits<marker_t>::max() - 2 <= marker) {
npm ERR!       |                                                                    ^~~
npm ERR!       |                                                                    std::max
npm ERR! In file included from /usr/include/c++/11/algorithm:62,
npm ERR!                  from ../../../../nan/nan.h:61,
npm ERR!                  from ../src/main.cc:2:
npm ERR! /usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
npm ERR!  3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
npm ERR!       |     ^~~
npm ERR! In file included from ../src/main.cc:5:
npm ERR! ../src/pf.h: At global scope:
npm ERR! ../src/pf.h:342:65: error: ‘numeric_limits’ is not a member of ‘std’
npm ERR!   342 |                         static constexpr cost_t obstacle = std::numeric_limits<cost_t>::max();
npm ERR!       |                                                                 ^~~~~~~~~~~~~~
npm ERR! ../src/pf.h:342:86: error: expected primary-expression before ‘>’ token
npm ERR!   342 |                         static constexpr cost_t obstacle = std::numeric_limits<cost_t>::max();
npm ERR!       |                                                                                      ^
npm ERR! ../src/pf.h:342:89: error: ‘::max’ has not been declared; did you mean ‘std::max’?
npm ERR!   342 |                         static constexpr cost_t obstacle = std::numeric_limits<cost_t>::max();
npm ERR!       |                                                                                         ^~~
npm ERR!       |                                                                                         std::max
npm ERR! In file included from /usr/include/c++/11/algorithm:62,
npm ERR!                  from ../../../../nan/nan.h:61,
npm ERR!                  from ../src/main.cc:2:
npm ERR! /usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
npm ERR!  3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
npm ERR!       |     ^~~
npm ERR! In file included from ../../../../nan/nan.h:58,
npm ERR!                  from ../src/main.cc:2:
npm ERR! /root/.node-gyp/16.13.0/include/node/node.h:821:7: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
npm ERR!   821 |       (node::addon_register_func) (regfunc),                          \
npm ERR!       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /root/.node-gyp/16.13.0/include/node/node.h:855:3: note: in expansion of macro ‘NODE_MODULE_X’
npm ERR!   855 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
npm ERR!       |   ^~~~~~~~~~~~~
npm ERR! ../src/main.cc:63:1: note: in expansion of macro ‘NODE_MODULE’
npm ERR!    63 | NODE_MODULE(native, init);
npm ERR!       | ^~~~~~~~~~~
npm ERR! make: *** [native.target.mk:209: Release/obj.target/native/src/main.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/mnt/kube-storage/Screeps/node_modules/node-gyp/lib/build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Linux 5.15.6-200.fc35.x86_64
npm ERR! gyp ERR! command "/usr/bin/node" "/mnt/kube-storage/Screeps/node_modules/.bin/node-gyp" "rebuild" "-C" "native"
npm ERR! gyp ERR! cwd /mnt/kube-storage/Screeps/node_modules/@screeps/driver/native
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-01-19T01_56_46_657Z-debug.log

Required dependencies are missing from package.json

I cloned the repository and ran into a few issues when I tried to set it up.

> [email protected] install /Users/RA80533/Desktop/screeps/driver/node_modules/fsevents
> node install

  SOLINK_MODULE(target) Release/.node
  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node
  SOLINK_MODULE(target) Release/fse.node
  COPY /Users/RA80533/Desktop/screeps/driver/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node
  COPY /Users/RA80533/Desktop/screeps/driver/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node
  TOUCH Release/obj.target/action_after_build.stamp
  TOUCH Release/obj.target/action_after_build.stamp

> [email protected] install /Users/RA80533/Desktop/screeps/driver/node_modules/isolated-vm
> node-gyp rebuild --release -j 4

  CXX(target) Release/obj.target/nortti/src/external_copy_nortti.o
  LIBTOOL-STATIC Release/nortti.a
  CXX(target) Release/obj.target/isolated_vm/src/isolate/allocator.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/class_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/environment.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/holder.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/inspector.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/stack_trace.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate/three_phase_task.o
  CXX(target) Release/obj.target/isolated_vm/src/context_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/external_copy.o
  CXX(target) Release/obj.target/isolated_vm/src/external_copy_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate.o
  CXX(target) Release/obj.target/isolated_vm/src/isolate_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/lib_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/native_module_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/reference_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/script_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/module_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/session_handle.o
  CXX(target) Release/obj.target/isolated_vm/src/transferable.o
  SOLINK_MODULE(target) Release/isolated_vm.node

> [email protected] postinstall /Users/RA80533/Desktop/screeps/driver/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js


> @screeps/[email protected] install /Users/RA80533/Desktop/screeps/driver
> node-gyp rebuild -C native && webpack

  CXX(target) Release/obj.target/native/src/main.o
  CXX(target) Release/obj.target/native/src/pf.o
  SOLINK_MODULE(target) Release/native.node
Executing post-build scripts
Hash: 2f277a711aa7386a2fe6
Version: webpack 3.11.0
Time: 244ms
            Asset    Size  Chunks                    Chunk Names
runtime.bundle.js  498 kB       0  [emitted]  [big]  main
   [0] (webpack)/buildin/global.js 509 bytes {0} [built]
   [2] ./lib/runtime/runtime.js 9.93 kB {0} [built]
   [3] ./lib/runtime/mapgrid.js 7.09 kB {0} [built]
   [4] ./lib/runtime/runtime-driver.js 4.09 kB {0} [built]
   [9] (webpack)/buildin/module.js 517 bytes {0} [built]
  [10] ./lib/path-finder.js 5 kB {0} [built]
    + 5 hidden modules

ERROR in ./lib/runtime/runtime-driver.js
Module not found: Error: Can't resolve '@screeps/common/lib/constants' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/runtime-driver.js 11:20-60
 @ ./lib/runtime/mapgrid.js
 @ ./lib/runtime/runtime.js

ERROR in ./lib/runtime/runtime-driver.js
Module not found: Error: Can't resolve '@screeps/common/lib/system' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/runtime-driver.js 12:17-54
 @ ./lib/runtime/mapgrid.js
 @ ./lib/runtime/runtime.js

ERROR in ./lib/runtime/runtime.js
Module not found: Error: Can't resolve '@screeps/engine/src/game/console' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/runtime.js 3:24-67

ERROR in ./lib/runtime/runtime.js
Module not found: Error: Can't resolve '@screeps/engine/src/game/game' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/runtime.js 2:17-57

ERROR in ./lib/runtime/runtime.js
Module not found: Error: Can't resolve '@screeps/engine/src/utils' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/runtime.js 5:18-54

ERROR in ./lib/runtime/mapgrid.js
Module not found: Error: Can't resolve '@screeps/pathfinding' in '/Users/RA80533/Desktop/screeps/driver/lib/runtime'
 @ ./lib/runtime/mapgrid.js 1:18-49
 @ ./lib/runtime/runtime.js
Runtime snapshot created (2656724 bytes)

I took a peek at the files referenced in the errors. It looks like they reference a few missing dependencies, namely:

  • @screeps/common is required in lib/bulk.js (line 3), lib/history.js (line 3), lib/index.js (line 4), lib/queue.js (line 4), lib/runtime/data.js (line 4), lib/runtime/make.js (line 1), lib/runtime/runtime-driver.js (lines 11 and 12), and lib/runtime/user-vm.js (line 8)
  • @screeps/engine is required by lib/runtime/runtime.js (lines 2, 3, and 5)
  • @screeps/pathfinding is required by lib/runtime/mapgrid.js (line 1)

Driver won't install

I'm trying to do npm install -g @screeps/driver since it doesn't seem to be a dependency of screeps/engine, and am receiving the following error:

> @screeps/[email protected] install /home/adam/npm-global/lib/node_modules/@screeps/driver
> node-gyp rebuild -C native

module.js:471
    throw err;
    ^

Error: Cannot find module 'nan'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at [eval]:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:25:33)
    at Object.exports.runInThisContext (vm.js:77:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:570:32)
    at bootstrap_node.js:357:29
gyp: Call to 'node -e "require('nan')"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/adam/npm-global/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-28-generic
gyp ERR! command "/opt/node/bin/node" "/home/adam/npm-global/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "-C" "native"
gyp ERR! cwd /home/adam/npm-global/lib/node_modules/@screeps/driver/native
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.