gitops-secrets-nodejs icon indicating copy to clipboard operation
gitops-secrets-nodejs copied to clipboard

Using with ` "type": "module",` in package.json / ES6

Open matoni109 opened this issue 1 year ago • 0 comments

Hi Team,

Trying to spin this up for a nodejs app and running into issues as we have

"type": "module",

set in our package.json

[nodemon] starting `node src/server.js`
file:///Users/me/code/platform-gateway/lib/secrets.js:3
const secrets = require("gitops-secrets/no-fs");
                ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/Users/me/code/platform-gateway/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///Users/me/code/platform-gateway/lib/secrets.js:3:17

Is there an easy enough way around this ?

Chris :)

matoni109 avatar Aug 17 '22 03:08 matoni109