-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛 Bug]: Cannot use import statement outside a module with Node 18.19.0 #11825
Comments
Simply do not run 'npm init' before running 'npm init wdio .' and it should work just fine |
The issue is that because you initialised the package twice it is missing the type property in the package.json |
Hi @erwinheitzman,
Adding As said this is working fine on lower and higher node versions, just on node 18.19.0 it runs into this issue. On node 18.18.2 and 20.10.0 I can use either of the type values in the package.json or just leave the property out as in my repo and wdio works without issue. |
I did not say to manually add it, I said that you should not instantiate the project twice in a row. Simply running 'npm init wdio@latest .' With the node version you shared, works fine |
That said, if the git repo already had typescript installed, I know this is currently an issue as it won't install any TS related packages for example |
First of all thank you very much for the quick help. Indeed it's working correctly if I just run But I'm still confused how to fix an existing ts repo where wdio was installed later on (without type module) and which was running fine on node 18 until the recent update to 18.19.0. Therefore I tried to add the type module to my sample repo, throw away the package-lock and node_modules to do a fresh reinstall but still I then run into this |
It's probably unrelated to node and is likely just a coincidence. Regarding the difference, I assume that typescript was already installed before you ran the I'll keep this issue open and look into this specific issue as someone ran into this not too long ago as well. |
My hunch is that it has to do with this change that was introduced in Node.js v18.19:
|
Thanks for reporting! We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers! |
Have you read the Contributing Guidelines on issues?
WebdriverIO Version
latest ("@wdio/cli": "^8.24.13")
Node.js Version
18.19.0
Mode
WDIO Testrunner
Which capabilities are you using?
No response
What happened?
This is a follow-up of issue #10901. I started with WDIO installation following these steps
npm init
npm init wdio
and accepted the default behavior in most cases (using typescript)npm run wdio
and faced error (see log output)The same is working when running either on node 18.18.2 or 20.10.0. The same error occured before on node 20 but was resolved with PR #11202. However, node 18.19.0 is now also using npm 10.2.3 and the if statement added with PR #11202 only checks on
nodeMajorVersion() >= 20
to set additional node options. Thus I assume that the root cause is npm 10.What is your expected behavior?
Running the generated wdio project on node 18.19.0 shall work without issues as it does on node 18.18.2 and 20.10.0
How to reproduce the bug.
npm install
npm run wdio
with node 18.19.0Relevant log output
Code of Conduct
Is there an existing issue for this?
The text was updated successfully, but these errors were encountered: