I type this command in the directory of my contract: truffle compile
And I get this error:
C:\Users\nick\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\cli.js:93
let removedInfo = new RegExp(identifyingInfo, "g");
^
SyntaxError: Invalid regular expression: /C:\Users\nick\AppData\Roaming\npm\node_modules\/: \ at end of pattern
at new RegExp (<anonymous>)
at Object.<anonymous> (C:\Users\nick\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\cli.js:93:1)
at cb (util.js:353:39)
at callbackifyOnRejected (util.js:337:10)
at process._tickCallback (internal/process/next_tick.js:63:19)
What do I do to fix this?
I expect the command to compile my contracts.
Truffle v5.0.7 (core: 5.0.7)
Solidity - 0.5.5 (solc-js)
Node v10.15.3
Hey @mudgen ! Could you share a link to your truffle project?
@CruzMolina Thanks for looking into this.
My truffle project is not public. What do you want to see?
Hi @mudgen, I may know what's going on here. Will take a look soon and get back to you!
@CruzMolina I looked in the code and I think I see the problem:
In the second line the return value is not assigned back to identifyingInfo.
let identifyingInfo = directory.split("truffle")[0];
identifyingInfo.replace(/\//gi, "\\/");
let removedInfo = new RegExp(identifyingInfo, "g");
error = error.replace(removedInfo, "");
@CruzMolina Now that I see this bug, how do I fix it in my truffle?
I tried editing C:\Users\nick\AppData\Roaming\npm\node_modules\build\cli.bundled.js to fix it but that did not do anything.
So I commented out the above lines from the file and now it is working.
hi @mudgen, I'm glad you found a temporary fix! What's actually going on is that the regex there isn't accounting for windows file paths properly. Since you are the one that located the problem, if you'd like to make a PR, it would be to fix the regex here: https://github.com/trufflesuite/truffle/blob/develop/packages/truffle-core/cli.js#L92
Let me know if you'd like to take a crack at it, otherwise I'll do it and it will go in the next release.
@fainashalts Thanks. I would like to but I am crunched for time and I don't know when I would get to it.
No problem @mudgen, I've got it. Thanks for pointing this out, we appreciate it!
@fainashalts Having a similar error over here. Thanks for looking into it.
EDIT: "truffle compile" works for me, whereas "truffle migrate" leads to the same error as outlined above. Using windows os as well.
@PizBernina @mudgen I have fixed this, it should be live in our next release. @mudgen's fix should take care of it in the short term. Thank you for bringing this to our attention!
@PizBernina, the reason you saw this happen in a different command is because the regex error only throws inside of another error. So you likely had an error in your migration somewhere. Once the regex is fixed you'll be able to see what the actual error was.
This issue is fixed as of v5.0.8. Closing, thank you for finding and reporting it!
Thank you for paying attention to this issue and fixing it!!!!
Thanks for creating awesome stuff & the quick response!
Aw thanks @mudgen and @PizBernina! Glad to help and to be working on such an awesome set of tools! :)
Glad to hear there's a fix -- I'm running into this too with truffle compile:
C:\Users\Owner\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\command.js:120
callback(err);
^
SyntaxError: Invalid regular expression: /C:\Users\Owner\AppData\Roaming\npm\node_modules\/: \ at end of pattern
at new RegExp (
at C:\Users\Owner\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\cli.js:93:1
at Command.run (C:\Users\Owner\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\command.js:120:1)
at Object.
at __webpack_require__ (C:\Users\Owner\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap 5543b191bb2cde506945:19:1)
at C:\Users\Owner\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap 5543b191bb2cde506945:65:1
at Object.
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
hey @mapachurro , do you still run into that error message on the latest version of truffle? (5.0.8)
Most helpful comment
@PizBernina @mudgen I have fixed this, it should be live in our next release. @mudgen's fix should take care of it in the short term. Thank you for bringing this to our attention!
@PizBernina, the reason you saw this happen in a different command is because the regex error only throws inside of another error. So you likely had an error in your migration somewhere. Once the regex is fixed you'll be able to see what the actual error was.