basemaps icon indicating copy to clipboard operation
basemaps copied to clipboard

npm install @basemap/sprites is missing modules

Open pnorman opened this issue 1 year ago • 5 comments

Bug Description

When following the install instructions for @basemaps/sprites, you get an unusable install

Steps to Reproduce

Steps to reproduce the behavior:

  1. npm install @basemaps/sprites
  2. node_modules/.bin/basemaps-sprites

You get the error

internal/process/esm_loader.js:74
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'fs' imported from /home/pnorman/spirit/node_modules/@basemaps/sprites/build/cli.js
    at packageResolve (internal/modules/esm/resolve.js:664:9)
    at moduleResolve (internal/modules/esm/resolve.js:705:18)
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:798:11)
    at Loader.resolve (internal/modules/esm/loader.js:100:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:246:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:47:40)
    at link (internal/modules/esm/module_job.js:46:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Versions installed are

npm list
spirit@ /home/pnorman/spirit
└── @basemaps/[email protected]

pnorman avatar Mar 09 '23 05:03 pnorman

Hi @pnorman, I have attempted to reproduce this issue, I started from a fresh nodejs docker container and it all worked fine.

Here are the commands I ran.

docker run -it node:18 /bin/bash

mkdir test-folder
cd test-folder
npm init --yes 
npm install @basemaps/sprites

node_modules/.bin/basemaps-sprites --help

Could you provide more information about your nodejs versions and system setup?

blacha avatar Mar 15 '23 22:03 blacha

pnorman@took:~/sprites_test$ npm --version
7.5.2
pnorman@took:~/sprites_test$ nodejs --version
v12.22.12

This is on a clean Debian stable release

pnorman avatar Mar 16 '23 04:03 pnorman

Node v12 reached end of life in April 2022 https://github.com/nodejs/release#release-schedule Node v14 will each end of life at the end of April 2023,

The current LTS is v18, We only test back to node v16, However as far as I can v14 works as expected.

I see the docs mention > v12, I will update that.

blacha avatar Mar 16 '23 08:03 blacha

engines should also be set in package.json if there are minimum versions - Debian and Ubuntu LTS both have Node 12 in their latest release, so it's fairly common.

pnorman avatar Mar 19 '23 06:03 pnorman

engines should also be set in package.json if there are minimum versions

It is currently set as the default for what is needed for ESM.

I have made https://github.com/linz/basemaps/pull/2749 which will allow node12 to work with sprites. But then I have also made a PR to say that we only support node>16 with the engines https://github.com/linz/basemaps/pull/2748

But considering that it was EOL'd a year ago, I would highly recommend using something like fnm or n to install a current LTS.

blacha avatar Mar 20 '23 07:03 blacha