Trying to install graphql package with node [duplicate] - node.js

This question already has answers here:
npm ERR Refusing to install package with name <packageName> under a package also called <packageName>
(2 answers)
Closed 1 year ago.
npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "graphql" under a package
npm ERR! also called "graphql". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR!
npm ERR! For more information, see:

Change the name prop on your package.json to anything but graphql

Edit package.json
{
"name": "graphql-basic", # --> change name but don't graphql
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"express-graphql": "^0.12.0",
"graphql": "^15.4.0"
}
}

Related

Getting missing script: start error in npm

I get this error when I run npm start.
npm ERR! Missing script: "start"
npm ERR! Did you mean one of these?
npm ERR! npm star # Mark your favorite packages
npm ERR! npm stars # View packages marked as favorites
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER\AppData\Local\npm-cache\_logs\2022-04-28T13_04_19_260Z-debug.log
package.json has various sections, scripts is one of them, which allows you to write npm scripts which we can run using npm run <script-name>. The error you're getting is because your start script is missing in that section.
For a node app, your package.json file should look similar to this.
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.0",
"cors": "^2.8.5",
"express": "^4.17.3"
}
}
In the above code, focus on the scripts section. The following line is missing in your package.json file.
"scripts": {
"start": "node app.js",
},
Add this line and you're good to go.
Option_1: Control inside file "package.json":
"scripts": {
"start": "what command is here?",
},
Option_2: Control Terminal (folder) where you write command OR open the responding terminal for your project: right-click
on the project name -> "Open in integrated Terminal"
You have to put what command you need npm to run when you give npm start.
You have to write node index.js in scripts.start in your package.json file

Error around package files for Node.js Discord bot

I have a basic Discord bot I am trying to publish through Heroku because I can't host it locally anymore.
Should mention that it runs perfectly fine when hosted locally on my VM.
When trying to push to Heroku through cli or git I am getting an error which says:
npm ERR! cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install before continuing.
remote: npm ERR!
remote: npm ERR!
remote: npm ERR! Missing: enmap#^5.2.4
remote: npm ERR! Missing: eslint#^7.2.0
Tried googling and and still have no idea how these package files work, so would be grateful if someone could tell me what to change.
package.json
{
"name": "sidbot2",
"version": "2.3.2",
"description": "",
"main": "sidbot.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "sidilleth",
"license": "ISC",
"dependencies": {
"discord.js": "^12.2.0",
"enmap": "^5.2.4"
"eslint": "^7.2.0"
},
"devDependencies": {
"eslint": "^7.2.0"
}
}
Remove the eslint from dependencies as it is already present in the dev dependencies. It should look similar to this:
{
"name": "sidbot2",
"version": "2.3.2",
"description": "",
"main": "sidbot.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "sidilleth",
"license": "ISC",
"dependencies": {
"discord.js": "^12.2.0",
"enmap": "^5.2.4"
},
"devDependencies": {
"eslint": "^7.2.0"
}
}
Delete node_modules folder and execute npm install.
Also make sure that the all the changes made in package.json and package-lock.json has been committed to git.

Getting Error While starting lite-server in npm

i did a fresh "npm init". put entry point : "index.html"
then installed lite-server : npm install lite-server --save-dev
also updated the package.json and I Uninstalled, reinstalled tried everything but it's not working and
also tried npm cache clean --force but it's not working. can any one help with this error.
{
"name": "git-test",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "npm run lite",
"lite": "lite-server"
},
"author": "Sateesh",
"license": "ISC",
"dependencies": {
"lite-server": "^2.5.4"
}
}
But when I did "npm start" , getting this error
git-test#1.0.0 start D:\Coursera\git-test
> npm run lite
'npm' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! git-test#1.0.0 start: `npm run lite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the git-test#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sai\AppData\Roaming\npm-cache\_logs\2020-06-05T10_20_11_723Z-debug.log
I was too facing the same issue after a system shutdown, hence this worked for me:
First uninstall the current local lite-server in node_modules
npm uninstall lite-server
Install lite-server globally and try running the same command
npm install -g lite-server
then hit:
npm start
This fixed the issue for me, thank you
Here's my Json file script if you want to have a look
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},
You don't seem to have node/npm installed and configured properly (PATH issues).
I would suggest you try to re-install Node.js using the official instructions for your platform (https://nodejs.org/en/download/) or by using a Node.js version manager like nvm (https://github.com/nvm-sh/nvm) or n (https://github.com/tj/n).
Using nvm or n, will allow you to dynamically switch Node.js version without having to re-install everything from scratch.
Just install the live-server globally,i think that should solve the issue.
sudo npm install --global lite-server
And in your package.json file you can change a little bit.
{
"name": "git-test",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "lite-server",
},
"author": "Sateesh",
"license": "ISC",
"dependencies": {
"lite-server": "^2.5.4"
}
}
After this run this on terminal
npm start
I think this should help :)
I had a similar issue,yarn start worked for

npm start showing weird error 1

I am new to react js and I have installed the dependencies for the application. Below is my package file:
package.json
{
"name": "reactapp",
"version": "0.0.0",
"description": "learn and test",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --hot"
},
"author": "john doe",
"license": "BSD-2-Clause",
"dependencies": {
"webpack": "~1.13.3",
"webpack-dev-server": "~1.16.2",
"react": "~15.3.2",
"react-dom": "~15.3.2"
},
"devDependencies": {}
}
It throws the error:
npm ERR! weird error 1
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! not ok code 0
But, in the terminal while it doesn't show up anything when in scripts it is
"test": "echo \"Error: no test specified\" && exit 1"
You need to use the sudo command while installing nodejs-legacy.
Executing sudo apt-get install nodejs-legacy from your command line/shell will resolve the issue.

npm install Giving error when Moving Project to Another Directory

I have a node project running in a directory, and I simply want to move it to another directory, let's say. When I try that, of course without the node_modules folder, and try to run npm install; it gives this error:
npm ERR! addLocal Could not install /Users/me_here
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v5.8.0
npm ERR! npm v3.7.3
npm ERR! No version provided in package.json
My package.json is as follows:
{
"name": "my-amazing-title",
"version": "1.0.0",
"description": "an amazing description",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "My full name",
"license": "MIT",
"dependencies": {
"express": "3.3.5",
"express-react-views": "file:../../",
"js-md5": "^0.4.0",
"react": "^0.14.0",
"react-dom": "^0.14.0",
"request": "^2.69.0",
"webpack": "^1.12.14"
}
}
I was able to npm install with your package.json by changing this line:
"express-react-views": "file:../../",
to
"express-react-views": "~0.10.0", //the current version at date of posting

Resources