No such file package.json when running npm i - node.js

When I run the following commands:
npm i && npm run
I get the following error:
npm WARN saveError ENOENT: no such file or directory, open '/Users/Singh/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/Singh/package.json'
npm WARN Singh No description
npm WARN Singh No repository field.
npm WARN Singh No README data
npm WARN Singh No license field.
Why am I getting this error and how do I fix it?

First check there is package.json file or not if not create package.json file using npm init

The problem is that you're in the wrong directory -- you're in your user directory. If you cloned something from a repository, make sure you navigate to that directory before running npm i:
cd path/to/cloned/project
npm i && npm run <script_here>

Related

npm install not working: "npm ERR! code ERR_SSL_WRONG_VERSION_NUMBER"

I can't install modules for my react app, when i run npm i it does this:
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion#1, but package-lock.json was generated for lockfileVersion#2. I'll try to do my best with it!
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\setprototypeof-b857a2ac\package.json'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\setprototypeof-b857a2ac\index.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\setprototypeof-b857a2ac\index.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\setprototypeof-b857a2ac\LICENSE'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\rc-5aecd98b\test\ini.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\setprototypeof-b857a2ac\README.md'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\rc-5aecd98b\test\nested-env-vars.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\rc-5aecd98b\test\test.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\term-size-f230f088\vendor\windows\term-size.exe'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\ast-types-5383d6cc\def\type-annotations.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\marco\Code\backend\node_modules\.staging\ast-types-5383d6cc\def\typescript.js'
npm WARN backend#1.0.0 No description
npm WARN backend#1.0.0 No repository field.
npm ERR! code ERR_SSL_WRONG_VERSION_NUMBER
npm ERR! errno ERR_SSL_WRONG_VERSION_NUMBER
npm ERR! request to https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz failed, reason: 4376:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:308:
npm ERR!
I tried reinstalling npm and it does the same thing. I tried with another project and I'm getting the same error. I found another question where someone had the same problem but noone replied. I even tried to set the npm registry to http://registry.npmjs.org instead of https://registry.npmjs.org, and setting the strict-ssl option to false, but it still won't work.
My npm version is 6.14.13 and my node version is v14.17.1.
Any help?
P.S.: I'm not using a proxy
Quick solution would be to delete node_modules and package-lock.json, so that when you reinstall the packages, they get installed with the lockfileVersion#1 instead of lockfileVersion#2.
I wouldn't suggest that solution though, as if you work in a team you would be forcing the others to do the same in order to fix it.
The problem is the npm version v6.x.x supports lockfileVersion#1 while v7.x.x supports lockfileVersion#2.
So a better solution would be to simply update your npm version to a v7 and higher.
Here you can find an interesting related discussion about it: Is there any way to fix package-lock.json lockfileVersion so npm uses a specific format?

Module 'googleapis' is not listed as dependency in package.json

Step 1: I try to add googleapis as dependency and got the error
$ npm install googleapis
npm WARN saveError ENOENT: no such file or directory, open '[home]/package.json'
npm WARN enoent ENOENT: no such file or directory, open '[home]/package.json'
npm WARN saly No description
npm WARN saly No repository field.
npm WARN saly No README data
npm WARN saly No license field.
Question: Why is it looking for the file in my home directory as opposed to my project directory? Especially since I am making the call from my project directory.
Step 2: I misunderstood the error and proceeded to deploying my project and that's where I got the error
Module 'googleapis' is not listed as dependency in package.json
Step 3: I now try npm i googleapis --save but I still get the same errors as in steps 1 and 2.
It seems that the problem was due to that I forgot to cd into the functions directory before I tried to install the dependencies.

npm install from tgz created with npm pack

I've created a .tgz file with npm pack. When trying to install it npm prints out the following error:
D:\tmp>npm install package-0.0.1.tgz
npm WARN saveError ENOENT: no such file or directory, open 'D:\tmp\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'D:\tmp\package.json'
npm WARN tmp No description
npm WARN tmp No repository field.
npm WARN tmp No README data
npm WARN tmp No license field.
It looks like npm for some reason does not extract the contents of my .tgz package, meaning all the .js files, package.json etc. although everything is there. Apparently it only tries to install the dependencies listed in my package.
Should it really work this way or I'm doing something wrong?
This error means you are not in a directory that has a package.json file and you are using the command that installs a package as a dependency into an existing, (local) npm project's package.json.
To install your package globally (just to test if it can be installed):
npm install -g package-0.0.1.tgz
Or, if you want to install/add it as a dependency to some other npm project (like a test harness), first make sure that npm project has a package.json, and then :
test-harness-dir> npm install package-0.0.1.tgz

issue using npm to install upper-case module on linuxmint OS

npm WARN saveError ENOENT: no such file or directory, open '/home/spipl8/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/spipl8/package.json'
npm WARN spipl8 No description
npm WARN spipl8 No repository field.
npm WARN spipl8 No README data
npm WARN spipl8 No license field.
this all error was occur when i try to install the upper-case modules of node.js NPM on linux mint please help me out to solve it.
I guess this is not the issue with npm, the error is saying it cannot find package.json in your directory.

How to fix the "npm install error" when installing "Botkit"?

I am a newbie machine learning programmer trying get how to install the botkit tool for creating AI messaging bots from the bot kit studio.
Botkit was installed but the following errors are shown in my terminal:
Rakeshs-MacBook-Air:~ niharika$ npm install
npm WARN enoent ENOENT: no such file or directory, open '/Users/niharika/package.json'
npm WARN niharika No description
npm WARN niharika No repository field.
npm WARN niharika No README data
npm WARN niharika No license field.
Rakeshs-MacBook-Air:~ niharika$ npm install --productions
npm WARN enoent ENOENT: no such file or directory, open '/Users/niharika/package.json'
npm WARN niharika No description
npm WARN niharika No repository field.
npm WARN niharika No README data
npm WARN niharika No license field.
I can't seem to figure out what the package.json file is supposed to be in order to run botkit studio.
This error does not have much to do with Botkit, but more to do with where you are running the npm install. You are running it in your /Users/niharika path. If you cloned down botkit into that directory then you will need to cd into it first. Your path will look more like /Users/niharika/botkitslackstarter/. Then run npm install which will look for a package.json in the root and install all dependencies so then you will be able to run node bot.js to start the application. Best of luck.
Step 1:
npm install
Step 2:
npm install botkit

Resources