slack-notify icon indicating copy to clipboard operation
slack-notify copied to clipboard

Error in node_module in new version of slack-notify

Open deepak-buildd opened this issue 2 years ago • 8 comments

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)
    

deepak-buildd avatar Nov 21 '22 07:11 deepak-buildd

Having same issue here

thangphung1310 avatar Nov 23 '22 17:11 thangphung1310

+1 same here

@andrewchilds

abhimishra01 avatar Nov 29 '22 10:11 abhimishra01

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?

andrewchilds avatar Nov 29 '22 19:11 andrewchilds

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

abhimishra01 avatar Nov 30 '22 04:11 abhimishra01

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

abhimishra01 avatar Mar 04 '23 17:03 abhimishra01

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

vinit-poojary avatar Aug 24 '23 06:08 vinit-poojary

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/[email protected]/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/[email protected]/node_modules/esbuild/lib/main.js:1649:15)
    at /Users/nik/Sites/meet-quantifly/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1058:25
    at /Users/nik/Sites/meet-quantifly/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1003:52
    at buildResponseToResult (/Users/nik/Sites/meet-quantifly/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1056:7)
    at /Users/nik/Sites/meet-quantifly/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1085:16
    at responseCallbacks.<computed> (/Users/nik/Sites/meet-quantifly/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:703:9)
    at handleIncomingPacket (/Users/nik/Sites/meet-quantifly/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:762:9)
    at Socket.readFromStdout (/Users/nik/Sites/meet-quantifly/node_modules/.pnpm/[email protected]/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.

Scorpio3310 avatar Oct 25 '23 23:10 Scorpio3310

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

osfieldgaga avatar Nov 04 '23 15:11 osfieldgaga