ckeditor / ckeditor5

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.
https://ckeditor.com/ckeditor-5
Other
9.35k stars 3.68k forks source link

custom build start with npm install, get "Cannot set properties of null (setting 'parent')" error #14845

Open ChenShuy1 opened 1 year ago

ChenShuy1 commented 1 year ago

πŸ“ Provide detailed reproduction steps (if any)

  1. git clone -b stable https://github.com/ckeditor/ckeditor5.git
  2. npm install

βœ”οΈ Expected result

install all dependencies

❌ Actual result

when I use npm install, it's like:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: ckeditor5@39.0.1
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!   dev react@"^18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.13.1 || ^17.0.0" from @ckeditor/ckeditor5-react@3.0.3
npm ERR! node_modules/@ckeditor/ckeditor5-react
npm ERR!   dev @ckeditor/ckeditor5-react@"^3.0.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/syc/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/syc/.npm/_logs/2023-08-23T03_37_16_080Z-debug-0.log

then I tried npm install --force, it's like:

npm WARN using --force Recommended protections disabled.
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @ckeditor/ckeditor5-react@3.0.3
npm WARN Found: react@18.2.0
npm WARN node_modules/react
npm WARN   dev react@"^18.2.0" from the root project
npm WARN   1 more (react-dom)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^16.13.1 || ^17.0.0" from @ckeditor/ckeditor5-react@3.0.3
npm WARN node_modules/@ckeditor/ckeditor5-react
npm WARN   dev @ckeditor/ckeditor5-react@"^3.0.3" from the root project
npm WARN
npm WARN Conflicting peer dependency: react@17.0.2
npm WARN node_modules/react
npm WARN   peer react@"^16.13.1 || ^17.0.0" from @ckeditor/ckeditor5-react@3.0.3
npm WARN   node_modules/@ckeditor/ckeditor5-react
npm WARN     dev @ckeditor/ckeditor5-react@"^3.0.3" from the root project
npm ERR! Cannot set properties of null (setting 'parent')

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/syc/.npm/_logs/2023-08-23T03_37_47_219Z-debug-0.log

❓ Possible solution

I dont know😒

πŸ“ƒ Other details


If you'd like to see this fixed sooner, add a πŸ‘ reaction to this post.

Reinmar commented 1 year ago

cc @ckeditor/ckeditor-5-devops

Reinmar commented 1 year ago

Same on the CI:

No idea that it started happening today. A new npm version changed something or wat?

pomek commented 1 year ago

I suggest upgrading this old version (3.0.0) to the latest in the project root. 3.0.0 does not support React 18. It was added in 4.0.1. However, CKE 5 uses 18 somewhere.

I wouldn't be surprised if this commit introduced the regression: https://github.com/ckeditor/ckeditor5/commit/dbe440fa88b71ab0d7ac6fe638ac832023d09f54.

Regarding the CI. Please, wait for the final migration. Its progress can be tracked:

ChenShuy1 commented 1 year ago

I have tried to modify the @ckeditor/ckeditor5-react version from ^3.0.3 to ^4.0.1, but it still not working. terminal information:

$ npm install
npm ERR! Cannot set properties of null (setting 'parent')

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/syc/.npm/_logs/2023-08-24T06_42_41_257Z-debug-0.log
pomek commented 1 year ago

Updating the package to the latest version also does not work. I had slightly different results while installing ^5, but in the end, it crashed due to a lack of access to husky (ckeditor5 post-install hook).

pomek commented 1 year ago

Removing any reference to the React integration package also does not help. Npm ends with the npm ERR! Cannot set properties of null (setting 'parent') error.

przemyslaw-zan commented 1 year ago

The issue seems to be related to two devDependencies:

Removing both lets us perform successful install.

When only cke5-react is removed, we get this error:

null ``` npm ERR! Cannot set properties of null (setting 'parent') ```

When only cke5-rtc is removed, we get this error:

ERESOLVE ``` npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: ckeditor5@39.0.2 npm ERR! Found: react@18.2.0 npm ERR! node_modules/react npm ERR! dev react@"^18.2.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@"^16.13.1 || ^17.0.0" from @ckeditor/ckeditor5-react@3.0.3 npm ERR! node_modules/@ckeditor/ckeditor5-react npm ERR! dev @ckeditor/ckeditor5-react@"^3.0.0" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. ```

Here are the combinations I've tested:

Without cke5-rtc With cke5-rtc
cke5-react at v3 ERESOLVE ERESOLVE
Without cke5-react βœ… null
cke5-react bump to v4 βœ… null
cke5-react bump to v5 βœ… null
cke5-react bump to v6 ERESOLVE ERESOLVE
przemyslaw-zan commented 1 year ago

After changing the name field in the root package.json to something else, eg. ckeditor5-foo the null error disappears:

Without cke5-rtc With cke5-rtc
cke5-react at v3 ERESOLVE ERESOLVE
Without cke5-react βœ… βœ…
cke5-react bump to v4 βœ… βœ…
cke5-react bump to v5 βœ… βœ…
cke5-react bump to v6 ERESOLVE ERESOLVE
mvprabhu-ma commented 1 year ago

Done the following:

Removed (from devDependencies):

"@ckeditor/ckeditor5-react": "^3.0.0"
"@ckeditor/ckeditor5-real-time-collaboration": "39.0.2"

Changed the name field in the root package.json to ckeditor5-Venkat

But, still getting this:

C:\RnD\ckeditor5\ckeditor5\packages\ckeditor5-build-classic>npm i
npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.

> ckeditor5-Venkat@39.0.2 postinstall
> node ./scripts/postinstall.js

node:internal/modules/cjs/loader:1080
  throw err;
  ^

Error: Cannot find module 'husky'
Require stack:
- C:\RnD\ckeditor5\ckeditor5\scripts\postinstall.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (C:\RnD\ckeditor5\ckeditor5\scripts\postinstall.js:15:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'C:\\RnD\\ckeditor5\\ckeditor5\\scripts\\postinstall.js' ]
}

Node.js v18.17.1
npm ERR! code 1
npm ERR! path C:\RnD\ckeditor5\ckeditor5
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node ./scripts/postinstall.js

npm ERR! A complete log of this run can be found in: C:\Users\prabhuv1\AppData\Local\npm-cache\_logs\2023-09-08T04_48_39_577Z-debug-0.log
pomek commented 1 year ago

I upgraded the used major version in the @ckeditor/ckeditor5-react package to 6. (change)

Then, I cloned the repository:

git clone git@github.com:ckeditor/ckeditor5 --depth 2 --single-branch --branch stable

Then, updated package.json to drop workspaces. Npm and yarn are incompatible, but I think yarn understands npm syntax so that we can simplify.

diff --git a/package.json b/package.json
index 89177fd..0f9e7fc 100644
--- a/package.json
+++ b/package.json
@@ -208,13 +208,5 @@
     "packages/*/src/lib/**",
     "coverage/**",
     "external/**"
-  ],
-  "workspaces": {
-    "packages": [
-      "packages/*",
-      "external/*",
-      "external/*/packages/*",
-      "."
-    ]
-  }
+  ]
 }

Executing npm install ends with some alerts, but looks like it works.

> ckeditor5@39.0.2 postinstall
> node ./scripts/postinstall.js

husky - Git hooks installed

up to date, audited 2071 packages in 6s

252 packages are looking for funding
  run `npm fund` for details

25 vulnerabilities (2 low, 5 moderate, 15 high, 3 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

Due to a lack of workspaces, the entire environment does not use the source of packages. Instead, if installed packages from npm.

Let me see if we can have workspaces too.

pomek commented 1 year ago

Finally, I installed the project using npm. Packages are linked (packages/ and node_modules/@ckeditor).

I proposed a PR #14956. Perhaps we can merge it next week if the proposed changes look good.

pomek commented 1 year ago

Unfortunately, I had a local copy of package-lock.json that helped resolve versions of dependencies. After the removal of this file, I have no progress.

After spending over 2 hours debugging this problem, I have no idea how to progress it. We have some issues with package.json, which yarn tolerates, accepts, and can resolve. Unfortunately, npm can't by default. Enabling the legacy peer deps option goes "smoothly".

mvprabhu-ma commented 12 months ago

Any workaround?

pomek commented 12 months ago

We recommend using Yarn@1. Is it possible for you?

mvprabhu-ma commented 11 months ago

We recommend using Yarn@1. Is it possible for you?

Yes... it worked