Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm ERR! notarget No matching version found for @liferay/js-toolkit-core@^5.0.1. #848

Closed
1 of 4 tasks
0xAnakin opened this issue Feb 10, 2022 · 22 comments
Closed
1 of 4 tasks

Comments

@0xAnakin
Copy link

0xAnakin commented Feb 10, 2022

  • πŸ€” Question
  • πŸ› Bug report
  • 🎁 Feature request
  • πŸ€·β€β™€οΈ Other

I was trying to adapt a newly created angular(v13) app.
After entering yo liferay-js:adapt the process started and while the npm install was running I got the following dependency error:

npm ERR! code ETARGET
npm ERR! notarget No matching version found for @liferay/js-toolkit-core@^5.0.1.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

node version: 16.14.0

packages installed globally:

β”œβ”€β”€ @angular/[email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
└── [email protected]

@0xAnakin
Copy link
Author

0xAnakin commented Feb 10, 2022

It seems you haven't published version 5.0.1 on npm

https://www.npmjs.com/package/@liferay/js-toolkit-core?activeTab=versions

@izaera
Copy link
Member

izaera commented Feb 10, 2022

@0xAnakin I've fixed it. You are too fast πŸ˜…

@izaera izaera closed this as completed Feb 10, 2022
@izaera
Copy link
Member

izaera commented Feb 10, 2022

Let me know if some other issue arises. Thanks :-)

@izaera izaera self-assigned this Feb 10, 2022
@0xAnakin
Copy link
Author

@izaera did you upload [email protected] on npm registry cause I don't see a new version? πŸ˜…
Maybe I should uninstall and re-intall generator-liferay-js?

@izaera
Copy link
Member

izaera commented Feb 10, 2022

Nope, @liferay/js-toolkit-core has version 5.0.0, but the wrong dependency reference was in portal-base.

What package is requesting @liferay/js-toolkit-core 5.0.1 in your case? πŸ€”

@izaera
Copy link
Member

izaera commented Feb 10, 2022

This is the commit -> 380e149

@izaera
Copy link
Member

izaera commented Feb 10, 2022

And there are no references left in this whole repo πŸ‘‡, so everything should be OK...

imagen

@izaera
Copy link
Member

izaera commented Feb 10, 2022

I wonder why you are experiencing this error, in any case, because these packages I'm talking about are not related to the generator (the generator is from the JS Toolkit v2, and the new packages are for the next version of JS Toolkit) πŸ€”

@0xAnakin
Copy link
Author

0xAnakin commented Feb 10, 2022

@izaera I'm trying to adapt an existing angular app into liferay so I've installed npm install -g yo generator-liferay-js and then navigated inside the angular app directory and entered yo liferay-js:adapt.

The wizard prompts me if it should overwrite the package.json and this is what I have after it does:

{
  "name": "angular-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "build:liferay": "lnbs-build",
    "deploy:liferay": "npm run build:liferay && lnbs-deploy"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~13.2.0",
    "@angular/common": "~13.2.0",
    "@angular/compiler": "~13.2.0",
    "@angular/core": "~13.2.0",
    "@angular/forms": "~13.2.0",
    "@angular/platform-browser": "~13.2.0",
    "@angular/platform-browser-dynamic": "~13.2.0",
    "@angular/router": "~13.2.0",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.2.3",
    "@angular/cli": "~13.2.3",
    "@angular/compiler-cli": "~13.2.0",
    "@types/jasmine": "~3.10.0",
    "@types/node": "^12.11.1",
    "jasmine-core": "~4.0.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.1.0",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "typescript": "~4.5.2",
    "liferay-npm-build-support": "^2.28.3",
    "liferay-npm-bundler": "^2.28.3",
    "liferay-npm-bundler-preset-angular-cli": "^2.28.3"
  },
  "portlet": {
    "com.liferay.portlet.display-category": "sample",
    "javax.portlet.name": "angularapp",
    "javax.portlet.security-role-ref": "power-user,user",
    "javax.portlet.resource-bundle": "content.Language",
    "com.liferay.portlet.instanceable": false,
    "com.liferay.portlet.header-portlet-css": "/angular-app/styles.css"
  }
}

As you can see the npm installation probably installs the following packages? πŸ€”

  • liferay-npm-build-support@^2.28.3
  • liferay-npm-bundler@^2.28.3
  • liferay-npm-bundler-preset-angular-cli@^2.28.3

Before the npm installation completes I get the following error:

npm ERR! code ETARGET
npm ERR! notarget No matching version found for @liferay/js-toolkit-core@^5.0.1.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

Some package requires a version that does not exist on npm. Here is the complete error log.

2022-02-10T13_50_06_451Z-debug-0.log

@0xAnakin
Copy link
Author

Also I've uninstalled generator-liferay-js globally and re-installed it just in case...

@izaera
Copy link
Member

izaera commented Feb 10, 2022

OK, so the problem must be in one of those deps. Let me check.

@izaera
Copy link
Member

izaera commented Feb 10, 2022

I've copied your package.json and run yarn install on it and it works.

Have you tried to delete the node_modules folder of your project and the package-lock.json file? Some of those must be holding a bogus reference...

@izaera
Copy link
Member

izaera commented Feb 10, 2022

This is what I get putting your package.json in an empty directory:

ivan@baco:~/Temporal/LL $ yarn
yarn install v1.22.17
info No lockfile found.
[1/4] Resolving packages...
warning @angular-devkit/build-angular > stylus > css > [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
warning liferay-npm-build-support > [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
warning liferay-npm-build-support > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
warning liferay-npm-build-support > request > [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
warning liferay-npm-build-support > babel-template > babel-runtime > [email protected]: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
warning liferay-npm-build-support > request > [email protected]: this library is no longer supported
warning liferay-npm-bundler > babel-core > babel-register > [email protected]: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 43.44s.
ivan@baco:~/Temporal/LL $ yarn why @liferay/js-toolkit-core
yarn why v1.22.17
[1/4] Why do we have the module "@liferay/js-toolkit-core"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@liferay/[email protected]"
info Reasons this module exists
   - "liferay-npm-bundler-preset-angular-cli#@liferay#portal-adapt-base#@liferay#portal-base" depends on it
   - Hoisted from "liferay-npm-bundler-preset-angular-cli#@liferay#portal-adapt-base#@liferay#portal-base#@liferay#js-toolkit-core"
info Disk size without dependencies: "9.28MB"
info Disk size with unique dependencies: "19.74MB"
info Disk size with transitive dependencies: "9.28MB"
info Number of shared dependencies: 120
Done in 0.50s.

@0xAnakin
Copy link
Author

0xAnakin commented Feb 10, 2022

Steps to reproduce the issue:

  • install nodejs LTS (16.14.0)
  • npm install -g yo generator-liferay-js @angular/cli
  • ng new angular-app
  • cd angular-app
  • yo liferay-js:adapt

Also if you delete package-lock.json after the angular app generation finishes, run yarn and then adapt the project, it does work. Maybe because it doesnt use npm anymore for some strange reason?

@izaera izaera reopened this Feb 11, 2022
@izaera
Copy link
Member

izaera commented Feb 11, 2022

I'm getting a similar error, but not for the same dep πŸ™„ :

ivan@baco:~/Temporal/issue-850/angular-app (master) $ npx yo liferay-js:adapt

πŸ‘‹ Welcome to Liferay JS Toolkit project adapter 

βœ”οΈ We have detected a project of type angular-cli

It will be tuned accordingly, so that you can deploy it to your Liferay
server.

But first we need you to answer some customization questions...

? Under which category should your widget be listed? category.sample
? Do you have a local installation of Liferay for development? Yes
? Where is your local installation of Liferay placed? /opt/liferay

⚠️ Now your project files will be modified. As a consequence, Yeoman may
notify you about the existence of a conflict and prompt for permission 
to overwrite your files.

Make sure to answer 'a' or otherwise the adaptation to Liferay JS 
Toolkit will fail.

ℹ️ Note that you can also avoid this conflict warning providing the 
'--force' argument to Yeoman.

 conflict package.json
? Overwrite package.json? overwrite this and all others
    force package.json
   create .npmbuildrc
   create .npmbundlerrc
   create features/localization/Language.properties
    force .gitignore

βœ”οΈ Your project has been successfully adapted to Liferay JS Toolkit.

ℹ️ See http://bit.ly/js-toolkit-adapt for the full list of npm scripts 
that may be used in your newly adapted project.

Nevertheless, you can start with 'npm run deploy:liferay' to deploy it
to your Liferay server.



I'm all done. Running npm install for you to install the required dependencies. If this fails, try running the command yourself.


npm ERR! code ETARGET
npm ERR! notarget No matching version found for webpack-cli@^4.9.1.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ivan/.npm/_logs/2022-02-11T07_29_41_518Z-debug-0.log

@izaera
Copy link
Member

izaera commented Feb 11, 2022

If I cd to angular-app and run npm install again, it does work 🀷 (so it's not a matter of yarn vs npm, but simply running the install again; quite strange...)

Then, I've been able to find out what uses js-toolkit-core:

$ npm ls @liferay/js-toolkit-core
[email protected] /home/ivan/Temporal/issue-850/angular-app
└─┬ [email protected]
  └─┬ @liferay/[email protected]
    └─┬ @liferay/[email protected]
      └── @liferay/[email protected]

@izaera
Copy link
Member

izaera commented Feb 11, 2022

We have the "old" code from JS Toolkit v2 pointing to the "new" code in liferay-cli, because we don't want to maintain two versions in parallel. For some reason, because I published a wrong version of portal-base (1.1.0) pointing to an invalid js-toolkit-core (5.0.1) it looks like your setup is trying to use that one instead of (1.1.1).

I'm going to unpublish the incorrect portal-base version to avoid problems like this in the future, but I suspect you will be getting the same problem over and over because there's something in your system caching the wrong version.

Have you tried cleaning the npm cache? Or maybe look for files like *js-toolkit-core* in your whole system...

Another test you can do is what I did. Let it fail, then cd to angular-app and run npm install again, then the npm ls to see the dependency path.

The difference between npm and yarn may also be due to npm caching different things than yarn (as each tool uses its own cache).

@izaera
Copy link
Member

izaera commented Feb 11, 2022

Also, regarding the error I got (with webpack-cli@^4.9.1) there must be something wrong in npm, because that version exists πŸ‘‰ https://www.npmjs.com/package/webpack-cli/v/4.9.1 πŸ€”

@izaera
Copy link
Member

izaera commented Feb 11, 2022

For the record: I've deprecated @liferay/[email protected].

$ npm deprecate -f @liferay/[email protected] "This package version (1.1.0) contains an invalid version for dependency @liferay/js-toolkit-core: expect it to fail. Use version 1.1.1 instead."

@izaera
Copy link
Member

izaera commented Feb 11, 2022

I'll wait for the tests suggested here πŸ‘‰ #848 (comment) to take place before closing this issue.

@izaera
Copy link
Member

izaera commented Feb 11, 2022

@0xAnakin If you will be doing this πŸ‘‰ #850 (comment) and it works, just forget about my suggestions and close this issue πŸ‘

@0xAnakin
Copy link
Author

Yeap the new tool seems to work better, has some minor issues still tho, see #850 for more. I'm closing this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants