radarlabs / s2

Node.js JavaScript / TypeScript bindings for Google S2
Apache License 2.0
130 stars 19 forks source link

Could not resolve "mock-aws-s3" #73

Open TheUncharted opened 1 year ago

TheUncharted commented 1 year ago

Hello

I started a starter react project with vite and got thoses errors below I wanted to test it quickly in a frontend with mapbox and then put the logic in the back

To reproduce

import './App.css';

import viteLogo from '/vite.svg';
import { useState } from 'react';

import reactLogo from './assets/react.svg';

const s2 = require('@radarlabs/s2');

function App() {
  const [count, setCount] = useState(0);
  const s2LatLong = new s2.LatLng(32.715651, -117.160542);
  const cellCoveringOptions = { min: 6, max: 13, max_cells: 10 };
  const coveringCells = s2.RegionCoverer.getRadiusCovering(
    s2LatLong,
    10000,
    cellCoveringOptions
  );
  console.log(coveringCells.cellIds().map((cellId) => cellId.token()));
  return (
    <>
      <div>
        <a href="https://vitejs.dev" target="_blank">
          <img src={viteLogo} className="logo" alt="Vite logo" />
        </a>
        <a href="https://react.dev" target="_blank">
          <img src={reactLogo} className="logo react" alt="React logo" />
        </a>
      </div>
      <h1>Vite + React</h1>
      <div className="card">
        <button onClick={() => setCount((count) => count + 1)}>
          count is {count}
        </button>
        <p>
          Edit <code>src/App.tsx</code> and save to test HMR
        </p>
      </div>
      <p className="read-the-docs">
        Click on the Vite and React logos to learn more
      </p>
    </>
  );
}

export default App;
[ERROR] Could not resolve "mock-aws-s3"

    node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:43:28:
      43 │     const AWSMock = require('mock-aws-s3');
         ╵                             ~~~~~~~~~~~~~

  You can mark the path "mock-aws-s3" as external to exclude it from the bundle, which will remove
  this error. You can also surround this "require" call with a try/catch block to handle this
  failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "aws-sdk"

    node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:76:22:
      76 │   const AWS = require('aws-sdk');
         ╵                       ~~~~~~~~~

  You can mark the path "aws-sdk" as external to exclude it from the bundle, which will remove this
  error. You can also surround this "require" call with a try/catch block to handle this failure at
  run-time instead of bundle-time.

✘ [ERROR] Could not resolve "nock"

    node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:112:23:
      112 │   const nock = require('nock');
          ╵                        ~~~~~~

  You can mark the path "nock" as external to exclude it from the bundle, which will remove this
  error. You can also surround this "require" call with a try/catch block to handle this failure at
  run-time instead of bundle-time.
TheUncharted commented 1 year ago

adding the libs doe not generate the errors anymore but i got the following errors in the browser console

pnpm add @mapbox/node-pre-gyp@^1.0.10 aws-sdk@^2.1396.0 mock-aws-s3@^4.0.2 nock@^13.3.1

Uncaught ReferenceError: process is not defined at module2.exports.get_mockS3Http (s3_setup.js:108:3) at node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js (node-pre-gyp.js:15:49) at __require2 (chunk-6NOISVLF.js?v=fa4056a4:16:50) at node_modules/@radarlabs/s2/index.js (index.js:2:16) at __require2 (chunk-6NOISVLF.js?v=fa4056a4:16:50) at index.js:6:18

tmcscoobydoo commented 3 months ago

i'm getting the same error when i deploy my sveltekit website ,any idea how to remove it please ? , my problem is i don't have any line that importing mock-aws-s3