Skip to content

Conversation

@andykenward
Copy link
Contributor

When using the package in a new project svg-element-attributes v2.0.0 is installed causing eslint to error with the below error. This is because svg-element-attributes v2.0.0 is ESM only and must use import instead of require when using.

Doing a npm i -D svg-element-attributes@^1.3.1 to the new project solves the issue.

I suggest changing the semver version of svg-element-attributes from >=1.3.1 to ^1.3.1. To avoid users of this package from having this issue.

node v14.16.0
npm 6.14.12

...node_modules/svg-element-attributes/index.js
require() of ES modules is not supported.
require() of example-repo/node_modules/svg-element-attributes/index.js from example/node_modules/eslint-plugin-github/lib/rules/get-attribute.js is an ES module file as it is a .js file whose nearest parent package.json contains “type”: “module” which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove “type”: “module” from example-repo/node_modules/svg-element-attributes/package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1216:13)
    at Module.load (internal/modules/cjs/loader.js:1039:32)
    at Module._load (internal/modules/cjs/loader.js:932:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
    at Module.require (internal/modules/cjs/loader.js:1079:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (example-repo/node_modules/eslint-plugin-github/lib/rules/get-attribute.js:1:30)
    at Module._compile (internal/modules/cjs/loader.js:1199:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1039:32)

Signed-off-by: Andy Kenward [email protected]

When using the package in a new project svg-element-attributes v2.0.0 is installed causing eslint to error with “ES module”

Signed-off-by: Andy Kenward <[email protected]>
@andykenward andykenward marked this pull request as ready for review March 30, 2021 20:09
@andykenward andykenward requested a review from a team as a code owner March 30, 2021 20:09
Copy link
Contributor

@koddsson koddsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@koddsson koddsson merged commit 40e8afb into github:main Mar 31, 2021
@andykenward andykenward deleted the svg-element-attributes branch March 31, 2021 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants