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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Cannot use import statement outside a module #6

Open
philmirez opened this issue Jun 16, 2021 · 0 comments
Open

SyntaxError: Cannot use import statement outside a module #6

philmirez opened this issue Jun 16, 2021 · 0 comments

Comments

@philmirez
Copy link

Hello 馃憢

I'm in need of some help. I'm trying to use this within my local github action. I'm defaulting to the default environment for the action so I'm not compiling/transpiling. I was surprised when I saw this error since it's within the node_module directory. I know github actions default to node 12. I'm wondering why it isn't picking up the compiled/transpiled code? I'm not sure if this is isolated to this repo or to all my node_modules. I'm still investigating.

// <repo>/package.json
{
...
  "dependencies": {
    ...
    "to-semver": "^4.0.0"
  }
}
// <repo>/actions/contentful-action/src/action.js
const toSemver = require('to-semver')
// github action error
/home/runner/work/<repo>/node_modules/to-semver/index.js:1
import semver from 'semver';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Module._compile (internal/modules/cjs/loader.js:895:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/runner/work/<repo>/.github/actions/contentful-action/src/action.js:7:18)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/runner/work/<repo>/.github/actions/contentful-action/src/index.js:3:23)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
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

No branches or pull requests

1 participant