Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in node_module in new version of slack-notify #36

Open
deepak-buildd opened this issue Nov 21, 2022 · 8 comments
Open

Error in node_module in new version of slack-notify #36

deepak-buildd opened this issue Nov 21, 2022 · 8 comments
Labels
help needed When the maintainer needs help fixing this issue

Comments

@deepak-buildd
Copy link

deepak-buildd commented Nov 21, 2022

Please check this issue , I think we should have type : module in package.json

node_modules/slack-notify/src/esm/index.mjs:1
import https from 'https';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (vm.js:356:18)
    at Object._compile (/Users/Documents/node_modules/pirates/lib/index.js:136:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Object.newLoader (/Users/Documents/node_modules/pirates/lib/index.js:141:7)
    
@thangphung1310
Copy link

Having same issue here

@abhimishra01
Copy link

abhimishra01 commented Nov 29, 2022

+1
same here

@andrewchilds

@andrewchilds
Copy link
Owner

If I were to add type: "module" to package.json, it will break this library for what seems to be a silent majority of users that are still using the CJS-style require('slack-notify') approach. So I'd rather solve this in a way that continues to support both CJS/ESM.

I'm having trouble reproducing this issue locally. Can someone provide steps I can use to reproduce this issue?

@abhimishra01
Copy link

abhimishra01 commented Nov 30, 2022

If I were to add type: "module" to package.json, it will break this library for what seems to be a silent majority of users that are still using the CJS-style require('slack-notify') approach. So I'd rather solve this in a way that continues to support both CJS/ESM.

I'm having trouble reproducing this issue locally. Can someone provide steps I can use to reproduce this issue?

Hi, @andrewchilds

I am also not able to reproduce this error in a straightforward way locally, it is happening in one of our hosted APIs
I will try to replicate the same in a simple javascript repository and share here, in case I am unable to do we can find some more ways

@andrewchilds andrewchilds added the help needed When the maintainer needs help fixing this issue label Dec 2, 2022
@abhimishra01
Copy link

If I were to add type: "module" to package.json, it will break this library for what seems to be a silent majority of users that are still using the CJS-style require('slack-notify') approach. So I'd rather solve this in a way that continues to support both CJS/ESM.
I'm having trouble reproducing this issue locally. Can someone provide steps I can use to reproduce this issue?

Hi, @andrewchilds

I am also not able to reproduce this error in a straightforward way locally, it is happening in one of our hosted APIs I will try to replicate the same in a simple javascript repository and share here, in case I am unable to do we can find some more ways

update : unable to re-create this as this works in standalone codebase but due to some unknown reasons, our existing codebase fails to get it working

due to privacy reasons, I can't share the codebase related files, but I will see if I can replicate the environment and try to generate the error

@vinit-poojary
Copy link

I am facing the same error after the update is this thing fixed

ERROR in ./node_modules/slack-notify/src/cjs/index.js 1:14-30
Module not found: Error: Can't resolve 'https' in '/node_modules/slack-notify/src/cjs'

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 }

ERROR in ./node_modules/slack-notify/src/cjs/index.js 2:15-39
Module not found: Error: Can't resolve 'buffer' in '/node_modules/slack-notify/src/cjs'

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: { "buffer": require.resolve("buffer/") }'
	- install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "buffer": false }

webpack compiled with 2 errors and 1 warning

@Scorpio3310
Copy link

Hi @andrewchilds
I also encountered an error when using the Cloudflare adapter with SvelteKit during the build process.

error during build:
Error: Build failed with 1 error:
node_modules/.pnpm/slack-notify@2.0.6/node_modules/slack-notify/src/esm/index.mjs:1:18: ERROR: Could not resolve "https"
    at failureErrorWithLog (/Users/nik/Sites/meet-quantifly/node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:1649:15)
    at /Users/nik/Sites/meet-quantifly/node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:1058:25
    at /Users/nik/Sites/meet-quantifly/node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:1003:52
    at buildResponseToResult (/Users/nik/Sites/meet-quantifly/node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:1056:7)
    at /Users/nik/Sites/meet-quantifly/node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:1085:16
    at responseCallbacks.<computed> (/Users/nik/Sites/meet-quantifly/node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:703:9)
    at handleIncomingPacket (/Users/nik/Sites/meet-quantifly/node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:762:9)
    at Socket.readFromStdout (/Users/nik/Sites/meet-quantifly/node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:679:7)
    at Socket.emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:335:12)
 ELIFECYCLE  Command failed with exit code 1.

@osfieldgaga
Copy link

I am facing the same error after the update is this thing fixed

ERROR in ./node_modules/slack-notify/src/cjs/index.js 1:14-30
Module not found: Error: Can't resolve 'https' in '/node_modules/slack-notify/src/cjs'

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 }

ERROR in ./node_modules/slack-notify/src/cjs/index.js 2:15-39
Module not found: Error: Can't resolve 'buffer' in '/node_modules/slack-notify/src/cjs'

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: { "buffer": require.resolve("buffer/") }'
	- install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "buffer": false }

webpack compiled with 2 errors and 1 warning

After googling around, I found out that adding buffer in your dependencies removes the error involving it. Reproducing the same thing for https by adding https-browserify however doesn't help much since it's still showing the same error. I am unable to understand what exactly is wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help needed When the maintainer needs help fixing this issue
Projects
None yet
Development

No branches or pull requests

7 participants