admc / wd

A node.js client for webdriver/selenium 2.
Other
1.53k stars 402 forks source link

Error: Cannot find module '../build/safe-execute' #570

Open wKich opened 5 years ago

wKich commented 5 years ago

I get this error when I try to run screenshot tests in my project. I think error is appears after switching between branches. Here closed issue #466, but I don't understand why it closed. It's really frustrating

Error: Cannot find module '../build/safe-execute'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/kich/Work/skbkontur/retail-ui/node_modules/wd/lib/commands.js:22:27)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/kich/Work/skbkontur/retail-ui/node_modules/wd/lib/element-commands.js:10:16)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
justinfagnani commented 3 years ago

I somehow got this error in a project and I can't find a way to solve it yet. A fresh checkout and npm install still produces the error, and if I inspect the wd package, I can see the require for ../build/safe-execute and that the entire build/ directory just doesn't exist. This seems like some sort of clear packaging error, or a skipped postInstall build step. Anyone have ideas?

usergenic commented 3 years ago

@admc it appears that npm no longer builds the necessary scripts on post-install, can these just be built as part of the publishing process? I can't get any of the tools built with wd to function without hacks/workarounds.

admc commented 3 years ago

Hey folks, sorry this is breaking for you. I honestly haven't worked on this in such a long time that I'm not sure how to fix it. If someone comes up with a fix, id be happy to merge and publish. Maybe @jlipps or @imurchie might have an idea of what to do here?

jepstein-eagle commented 3 years ago

This issue has been a problem for our teams as well. As a temporary workaround, we added node node_modules/wd/scripts/build-browser-scripts.js to postinstall in our package.json. If someone has an idea how to fix this in this repo as per @admc that would be greatly appreciated.

joshuapinter commented 3 years ago

@jepstein-eagle Great work, thanks for sharing!

@admc I feel that pain. Would you recommend those of us still using wd to migrate to wdio sooner rather than later? Thanks for all your efforts on this btw.

jlipps commented 3 years ago

Hi everyone, I used to help maintain this project, but unfortunately haven't had time to keep it up to date on top of regular Appium maintenance. I definitely recommend wdio as a substitute. It's very well maintained and full featured. I've been using it for all my new projects for quite some time.

joshuapinter commented 3 years ago

@jlipps Thanks for the honesty and recommendation. Do you know of or have any recommendations on a guide/steps to migrate from wd to wdio? Thanks!

jlipps commented 3 years ago

@christian-bromann do you know of any guide like this?

christian-bromann commented 3 years ago

mhm 🤔 not really. We have written codemods to help Protractor users to migrate to WebdriverIO. Given that wd can be written in many flavors, e.g. using async/await, via chaining or callbacks it would be hard to do that for this tool.

@joshuapinter unfortunately I can't give you an easy solution here other than rewriting. I am happy to help in the process. Join our community channel if you have questions or come across any issues.

joshuapinter commented 3 years ago

@christian-bromann @jlipps Thanks for the tips, gents. We'll make the move at some point and ask any questions in the community channel. Cheers! 🍻

Gurjap commented 1 year ago

Yarn install --force worked for me