apostrophecms / apostrophecms/apostrophe
Apos2.222.0 - Invalid RegEx path.sep missing "\"
- Dominant language
- JavaScript
- Stars
- 4.6k
- Forks
- 650
- Avg merge
- 19h 21m
- Merged PRs (30d)
- 23
Description
Even though it isn't recommended to run ApostropheCMS on Windows, I've found a small bug which is worth opening a PR for.
## To Reproduce
Step by step instructions to reproduce the behavior:
1. Running ApostropheCMS 2 branch release-2.222.0 on Windows
2. `npm i` installs packages fine on Node 14,16 and 18
3. `npm start` is throwing an error with an invalid regular expression
## Expected behavior
Apostrophe should start as expected
## Describe the bug
Getting the following error when starting Apostrophe on a Windows environment:
```
kiichiro-toyoda-cms\node_modules\apostrophe\index.js:58
throw err;
^
SyntaxError: Invalid regular expression: /\node_modules\mocha\/: \ at end of pattern
at new RegExp ()
at getRoot (C:\Users\user\WebStormProjects\kiichiro-toyoda-cms\node_modules\apostrophe\index.js:259:35)
at module.exports (C:\Users\user\WebStormProjects\kiichiro-toyoda-cms\node_modules\apostrophe\index.js:35:33)
at Object. (C:\Users\user\WebStormProjects\kiichiro-toyoda-cms\app.js:334:35)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47
[nodemon] app crashed - waiting for file changes before starting...
```
A small update is required to a specific line within the root `index.js` file of the apostrophe release-2.222.0 branch, the following on line 259 should be updated from:
```
if (m.parent.filename.match(new RegExp(`${path.sep}node_modules${path.sep}mocha${path.sep}`))) {
```
to:
```
if (m.parent.filename.match(new RegExp(`${path.sep}node_modules${path.sep}mocha\${path.sep}`))) {
```
## Details
Windows uses
**Version of Node.js:**
Tested on Node 14, 16 and 18
**Server Operating System:**
Microsoft Windows
**Additional context:**
This is specific to Microsoft Windows, after forking at testing the above fix Apostrophe starts as expected including on both Linux and Mac.
Contributor guide
Assessment
This issue has not been assessed yet.