CICCIOSGAMINO / openweather-apis

Simple APIs for OpenWeatherMap.org basic services
GNU General Public License v3.0
44 stars 27 forks source link

I Found Some Problems in openweather-apis #49

Closed Kevinsorensen523 closed 1 year ago

Kevinsorensen523 commented 2 years ago
Screenshot 2022-05-25 111742

something like ERROR in ./node_modules/openweather-apis/index.js 16:14-30

CICCIOSGAMINO commented 2 years ago

HTTP is no longer usable .... check the CHANGELOG.md ... i think it's a webpack features! Can you add more stacktrace ?

JacobDB commented 2 years ago

I'm also seeing this, here's my output:

 Module not found: Error: Can't resolve 'http' in '/home/jacob/Repositories/project-name/node_modules/.pnpm/openweather-apis@4.4.2/node_modules/openweather-apis'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }
Module not found: Error: Can't resolve 'https' in '/home/jacob/Repositories/project-name/node_modules/.pnpm/openweather-apis@4.4.2/node_modules/openweather-apis'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
        - install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "https": false }
Module not found: Error: Can't resolve 'querystring' in '/home/jacob/Repositories/project-name/node_modules/.pnpm/openweather-apis@4.4.2/node_modules/openweather-apis'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "querystring": require.resolve("querystring-es3") }'
        - install 'querystring-es3'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "querystring": false }
[11:01:10] asset modern.e59690d9.js 782 KiB [emitted] [immutable] (name: modern) 1 related asset
asset service-worker.js 400 KiB [emitted] (name: service-worker) 1 related asset
asset fontawesome.7137b830.js 160 KiB [emitted] [immutable] (name: fontawesome) 1 related asset
asset legacy.cf3c8196.js 51.5 KiB [emitted] [immutable] (name: legacy) 1 related asset
asset wp-admin.3da752f7.js 6.1 KiB [emitted] [immutable] (name: wp-admin) 1 related asset

ERROR in ./node_modules/.pnpm/openweather-apis@4.4.2/node_modules/openweather-apis/index.js 14:13-28
Module not found: Error: Can't resolve 'http' in '/home/jacob/Repositories/project-name/node_modules/.pnpm/openweather-apis@4.4.2/node_modules/openweather-apis'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }
 @ ./src/assets/scripts/modern/weather.init.js 3:0-39 10:2-24 11:2-17 12:2-18 13:2-18 14:16-38

ERROR in ./node_modules/.pnpm/openweather-apis@4.4.2/node_modules/openweather-apis/index.js 16:14-30
Module not found: Error: Can't resolve 'https' in '/home/jacob/Repositories/project-name/node_modules/.pnpm/openweather-apis@4.4.2/node_modules/openweather-apis'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
        - install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "https": false }
 @ ./src/assets/scripts/modern/weather.init.js 3:0-39 10:2-24 11:2-17 12:2-18 13:2-18 14:16-38

ERROR in ./node_modules/.pnpm/openweather-apis@4.4.2/node_modules/openweather-apis/index.js 18:20-42
Module not found: Error: Can't resolve 'querystring' in '/home/jacob/Repositories/project-name/node_modules/.pnpm/openweather-apis@4.4.2/node_modules/openweather-apis'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "querystring": require.resolve("querystring-es3") }'
        - install 'querystring-es3'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "querystring": false }
 @ ./src/assets/scripts/modern/weather.init.js 3:0-39 10:2-24 11:2-17 12:2-18 13:2-18 14:16-38

webpack 5.74.0 compiled with 3 errors

I believe I've solved it, by adding the following to my webpack configuration, and installing the specified modules:

resolve: {
    alias: {
        "http": require.resolve("stream-http"),
        "https": require.resolve("https-browserify"),
        "querystring": require.resolve("querystring-es3"),
        "url": require.resolve("url/")
    }
},

I'm still testing, though, I just generated my key and I'm getting a 401, so I'm hoping that'll just fix itself in a couple of hours, as their documentation suggests.

EDIT: Still not working really, does this library not work in browser at all?

JacobDB commented 2 years ago

Not sure if this is a viable solution for others, but I just used fetch instead to work with the API directly, worked perfectly.

const TARGET = document.getElementById("weather-target");

if (TARGET) {
    fetch("https://api.openweathermap.org/data/2.5/weather?lat={LAT}&lon={LON}&units=imperial&appid={KEY}")
        .then((response) => {
            return response.json();
        })
        .then((json) => {
            TARGET.innerHTML = `${Math.round(json.main.temp)}&deg;F ${json.weather[0].description}`;
        });
}
CICCIOSGAMINO commented 2 years ago

Try with the latest module version... and let me know !

https://www.npmjs.com/package/@cicciosgamino/openweather-apis

npm i @cicciosgamino/openweather-apis