slack-notify
slack-notify copied to clipboard
Error in node_module in new version of slack-notify
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)
Having same issue here
+1 same here
@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?
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-stylerequire('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
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-stylerequire('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
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
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.
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