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

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.

Related

Error: Unable to resolve module `#react-native-community/toolbar-android`

Weirdly, the react-native-vector-icons was working well but by using ^ ("^6.6.0") for its version in the package.json file on the new release this error happens.
It's weird because two days ago it works well but now starting of my project ran to this error:
error: Error: Unable to resolve module #react-native-community/toolbar-android from node_modules\react-native-vector-icons\lib\toolbar-android.js: #react-native-community/toolbar-android could not be found within the project.
After reading this issue and trying many solutions I reach to two solutions:
You can delete all node_modules folder and put the version of react-native-vector-icons to "6.6.0" instead of "^6.6.0" and then install all packages again. absolutely, it is better to delete all caches and builds and start everything again. (NOT Recommended)
You can install the #react-native-community/toolbar-android by using the below command:
yarn add #react-native-community/toolbar-android
Or
npm install --save #react-native-community/toolbar-android
Note: Both of these solutions are temporary and soonly this bug will be fixed and there is no need to install the toolbar-android package.
Prev Update
I update the package to the version "^7.0.0" on my project and still, the issue is remaining, so this solution is currently perseverance.
New Update
this issue is fixed on version "^7.1.0" and there is no need to install the #react-native-community/toolbar-android.
Update the library
react-native-vector-icons
to the latest version.
I had this problem too.
In my case, only works when I removed and added the package again with the latest version (7.0.0).
yarn remove react-native-vector-icons
yarn add react-native-vector-icons
Had this EXACT same error. All I had to do was install toolbar-android & voilà!
npm install --save #react-native-community/toolbar-android
Go the path \node_modules\native-base\node_modules\react-native-vector-icons\lib\toolbar-android.js
Replace import ToolbarAndroid from '#react-native-community/toolbar-android' to import {ToolbarAndroid} from './react-native';
I also got the same error after upgrading from version 6 to 7. The issue can be fixed simply by resetting the cache.
Please try npm start -- --reset-cache
do this:
rm -rf node_modules/
rm -rf package.lock.json
npm i
react-native start --reset-cache
from your project directory:)
Just Import it direct from react native it solves my problem
node_modules\react-native-vector-icons\lib\toolbar-android.js
import { ToolbarAndroid } from 'react-native';
Same issue, I solved it:
My environment:
RN: 0.61.5
Node: v12.18.3
OS: Windows 10 Pro
You can install react-native-vector-icons latest version (current 7.0.0).
And do not run auto-link (react-native link react-native-vector-icons)
Finally, running react-native start --reset-cache
Good luck.
First let's understand the standard convention used in package.json for packege's version.
So if you see ~1.0.2 it means to install version 1.0.2 or the latest patch version such as 1.0.4. If you see ^1.0.2 it means to install version 1.0.2 or the latest minor or patch version such as 1.1.0.
Now, coming to the issue.
The issue is caused because you are having a version of react-native-vector-icons which is giving you some trouble.
Check it's version by this command under your project directory:
npm list react-native-vector-icons --version \ is it 6.6.0 ??
No ?? . There is the problem. You need strictly 6.6.0 but you got something else.
Solution:
Delete node_modules directory under your project. Change the version of react-native-vector-icons in package.json to 6.6.0 (basically remove ^ to tell npm to get me exactly what I want. Nothing more, nothing less !)
Then do npm install !
The other alternative is to use expo's vector Icons. Something like this.
import { Ionicons } from "#expo/vector-icons".
Then render your Icon like this;
<Ionicons
name="ios-exit-outline"
color={colors.danger}
size={28}
style={{ marginRight: -15 }}
/>
Edit this file node_modules\react-native-vector-icons\lib\toolbar-android.js
remove 'import ToolbarAndroid from '#react-native-community/toolbar-android';'
edit return null
for this case you have not toolbar-android in your modules file and as friends saying you can fix it by this command
windows users:
npm install --save #react-native-community/toolbar-android
Mac users:
yarn add #react-native-community/toolbar-android
But IN GENERAL: I wanna tell you an experience for you guys whenever you encounter with this kind of errors that start with "Unable to resolve module" .
if you have a look to the error we have a problem with the module that system is telling us.
if you have not that module . you can install it with the commands
Windows users:
npm install --save THE MODULE(attention: THE MODULE IS THE NAME OF PACKAGES OR MODULES that u need to install)
and Mac users:
yarn add THE MODULE(attention: THE MODULE IS THE NAME OF PACKAGES OR MODULES that u need to install)
for example lets look at this error:
error Unable to resolve module `#react-native-community/slider` from `App.js`: #react-native-community/slider could not be found within the project.
as you can see error is telling us this module could not be found within our project.
so we need install it with this command:
for windows programmers:
npm install --save #react-native-community/slider
and for mac programmers:
yarn add #react-native-community/slider
that's all.
I hope you understand me clearly and do not have problem with unable to resolve module errors and my command be useful for you.
best regards
Mehrad Karampour (MEH)

Installing react gives the following error

First, I make this globally, then I install my app.
Then I go to my project directories. Finally, when I am running the project it shows the error illustrated in the image below.
I have tried so many thing like uninstalling node.js then reinstalling again or deleting node module(s), etc. What more do you think, should I try? Thank you in advance.
Project is running at http://192.168.0.101/
Downgrading the react-script version to 2.1.8.
npm install react-scripts#2.1.8
npm start
Package json dependencies should get updated to
"dependencies": {
------------------
---------------------
"react-scripts": "2.1.8"
},

ng command not working [duplicate]

I am trying to create a project (named ngadmin) via the angular cli but it throws errors on this command: ng new ngadmin. The errors are:
fs: re-evaluating native module sources is not supported. If you are
using the graceful-fs module, please update it to a more recent
version.
You cannot use the new command inside an angular-cli project.
I am not sure what the problem is as this cli was working fine for me a few days ago.
Check in your username folder, if there is package.json and node_module exist. If they are there then delete them.
Notice: you may have created an angular project in your home/username directory. If you delete them it will work.
If using Linux, go to home and delete package.json.
I had this problem as well. Here is how I fixed it:
Go to package.json
Under "Dependencies", find "angular-cli": "^1.0.0-beta.18"
Delete this line ("angular-cli": "^1.0.0-beta.18")
Save file
Hope that helps!
The first warning regarding graceful-fs is due to the fact that angular-cli uses older version of graceful-fs pkg, nothing to worry about that.
The error "You cannot use the new command inside an angular-cli project" signifies you are inside an angular cli project, get out of the angular cli project using cd .. command and try running the command ng new ngadmin it will work.
there is a file package.json
Simply remove it and then Create project.
it will work for sure
Seems like i fixed my problem. I have no idea what happened but i noticed system32 was not in my PATH so i added that and uninstalled and reinstalled the angular-cli package. everything works like a charm now
I had the same issue, the thing was I was not closely following along the tutorial I was watching and I tried using the same directory, I used cd .. to move up in the file structure and it worked like a charm, hope this helps!
i had the same problem today, I started a fresh project and did
npm install -save #angular/cli
and received the error.
I just renamed the package.json to .json2 temporarily and it worked.
Delete the file package.json in current directory where you are trying to create. Then try to install again.
In windows cd/User,Find the package.json,package-lock.json file and delete both the files.
Restart your command prompt and you are ready to go.And try to use this command
npm install --save-dev #angular/cli#latest
You must have used local "npm install #angular/cli" command to install angular locally in your project.
Uninstall local angular using "npm uninstall #angular/cli"
install angular globally using "npm install -g #angular/cli"
and then try "ng new ngadmin"
Because "ng new projectName" will automatically install angular/cli locally as a dev-dependency

Using specific version of npm shrinkwrap

I am deploying my node.js app to Appfog but since their install script cannot parse npm-shrinkwrap.json the whole deploy process fails.
An example dependency in shrinkwrap.json today looks like this
"async": {
"version": "0.2.10",
"from": "async#0.2.10", <--- This line breaks install script at appfog
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz"
},
I went through the whole shrinkwrap file and removed the "from" part from each dependency declaration and i managed to upload my application, and it works.
So my question is , how do i use an older version of npm shrinkwrap so i can get the version of shrinkwrap.json that i need?
Appfog support told me i need to use version 1.1.21 but i have not succeeded in installing it.
Please ask if some info is missing.
if you just want to use an older version of npm, you can install it via npm (i know that sounds strange, but its possible)
npm install npm#1.1.21
edit: so you try to install a version of npm which does not exist. just run
npm view npm
and take a look at the property version, to see which versions you could install via npm.
you will see that 1.1.21 does not exist in the registry, which means that you should try to install it via github (see answer by #sakai).
but then you see the next problem. you are using node#0.10.26, and npm 1.1.21 is probably not compatible with node#0.10.x.
so i for myself see basically 2 possible solutions:
Solution 1:
use n (or maybe nvm for switching node-versions back and forth. you could try to install a node#0.8.x version and try to install npm#1.1.21 there, and when done with shrinkwrapping switch back to your current node version.
Solution 2
you could setup some kind of grunt/gulp-task (i hope you use one of them) to run grunt/gulp shrinkwrap, which generates your shrinkwrap.json (via npm shrinkwrap) and when done cleans up your shrinkwrap.json
Try this:
npm install https://github.com/npm/npm/archive/v1.1.21.tar.gz
node ./node_modules/npm/bin/npm-cli.js shrinkwrap
Another—possibly simpler—solution is to just include node_modules into your repo.
Related: Should I check in node_modules to git when creating a node.js app on Heroku?

npm install forked git with submodule

I'm trying to get npm to install node-gitteh as a dependency via npm install which reads from package.json. Unfortunately this npm package is broken in node 0.6.x, but no problem as there's a forked repo that fixes the issues (https://github.com/hughsk/node-gitteh.git).
Now the issue is that this forked repo has a submodule, so if I try to download the tar from github in the package.json:
, "dependencies" : {
"gitteh" : "https://github.com/hughsk/node-gitteh/tarball/master"
}
I get an error that equates to "submodule folder not found". If I clone the same repo manually and do a recursive submodule update and an npm install from the node-gitteh folder, it works fine, but I can't figure out how to get npm to do this.
I've had the same problem and so far have just relied on cloning my module into node_modules and doing a submodule update manually. It would be nice to have npm handle this automatically.
In package.json there's a scripts field (see npm docs)
So could do
"scripts":{"preinstall": "git submodule update -i -r"}
See https://github.com/isaacs/octave-test for an example of this.
According to the docs, you need to supply the git url in a special format.
Also, it needs to point to git repo (same address you would use for git clone), not the tarball provided by github.
In your case (git over https), it would be:
, "dependencies" : {
"gitteh" : "git+https://github.com/hughsk/node-gitteh"
}
Using this, npm will default to the master branch.

Categories