Skip to content

Conversation

lari-ks
Copy link

@lari-ks lari-ks commented Jan 28, 2025

Unable to run repo on a Windows or other OS.
295 issue link

Use Case for Proposal

I recently ran into an issue i wanted to take time to debug because i really wanted to use jodit in my Next.js project and i wanted to check if the demo could reproduce the same issue outside of Next or if it would be easier to debug with the repo locally - so this is why this is a problem if the repo cannot be run in different environments. These fixes allowed me to run and find the issue and open PR for it as well as these build fixes.

Opening this issue to link to PR.

The PR fixes 3 issues listed below with descriptions of the type of errors they throw in another environment i.e. Windows:

  1. npm run build
  2. npm run build:types
  3. npm run remove-css

These issues prevent the contributor or user from running build scripts on different OS environments.

Details of issues when trying to run those 3 scripts below:

  1. Using NODE_ENV instead of cross-env NODE_ENV is OS incompatible. cross-env makes it OS compatible which is good for a project that benefits from many contributors

$ npm run build

jodit-react@5.0.13 build
npm run build:react && npm run build:types

jodit-react@5.0.13 build:react
NODE_ENV=production node -r @swc-node/register ./node_modules/.bin/webpack --mode production

'NODE_ENV' is not recognized as an internal or external command,
operable program or batch file.

  1. Running npm run build:types broken
    Threw an error due to issue with remove-css - this is a simple fix in package.json
    Also could not build due to "skipLibCheck": true missing in tsconfig.types.json - threw errors about every .d.ts file, recommended to set to true so will be able to run build

jodit-react@5.0.13 remove-css
replace "import '[^']+.css';" '' ./build/**/*.ts

node:fs:1633
const stats = binding.lstat(
^

Error: ENOENT: no such file or directory, lstat 'C:\Users\user\jodit-react\build**.ts'
at Object.lstatSync (node:fs:1633:25)
at replacizeFileSync (C:\Users\user\jodit-react\node_modules\replace\replace.js:140:22)
at module.exports (C:\Users\user\jodit-react\node_modules\replace\replace.js:80:17)
at Object. (C:\Users\user\jodit-react\node_modules\replace\bin\replace.js:42:1)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
errno: -4058,
code: 'ENOENT',
syscall: 'lstat',
path: 'C:\Users\user\jodit-react\build\**\
.ts'
}

  1. Running npm run build broken (below)
    This is what happens when using this ./node_modules/.bin/webpack in Windows env (below)
    Fixed by updating webpack.config to .js and package.json (adding webpack script that allows webpack to run correctly in any environment)
    This allows npm run build:types and npm run build runs successfully.

$ npm run build

jodit-react@5.0.13 build
npm run build:react && npm run build:types

jodit-react@5.0.13 build:react
cross-env NODE_ENV=production node -r @swc-node/register ./node_modules/.bin/webpack --mode production

C:\Users\user\jodit-react\node_modules.bin\webpack:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\,/,g')")
^^^^^^^

SyntaxError: missing ) after argument list
at wrapSafe (node:internal/modules/cjs/loader:1281:20)
at Module._compile (node:internal/modules/cjs/loader:1321:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Object.newLoader [as .js] (C:\Users\user\jodit-react\node_modules\pirates\lib\index.js:121:7)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49

Node.js v20.13.1

Fixes #295

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

Successfully merging this pull request may close these issues.

Improve Build Scripts for Contributors & Users
1 participant