简体   繁体   中英

ENOLOCAL: can't find package.json file after publishing npm package

Ecosystem

using npm@6.1.0
using node@v8.11.1

Context

I have a JS project that includes a local dependencie :

package.json :

"dependencies": {
   "my_local_module": "file:my_local_module"
},

Then, I published the project as npm private package : so far everything is OK.

Issue

When I try to install my private package, I have this issue :

33 error code ENOLOCAL
34 error Could not install from "node_modules\@my_scope\my_project\my_local_module" as it does not contain a package.json file.

Of course, the package.json file exists. When I try to copy manually the project from gitHub instead of installing it with npm , it works perfectly fine but I really would like to make it works with :

npm install @my_scope\my_project 

Is there a specific way to publish packages when they include local dependencies or anything like that ? Thank you for your help.

You can try to delete your package-lock.json file

I had the same problem and error. The package-lock.json was still doing a reference to "file:my_local_module". I deleted it and re npm installed the module to make it work

I found a report of a similar issue within the npm cli github

https://github.com/npm/cli/issues/1756

It appears this may be an issue with npm v6 (I was using version 6.14.12). Updating npm to v7 seems to have solved this issue for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM