npm start error nodejs - node.js

I give the command npm start. Terminal responds:

Make sure you are in correct directory when you run npm install, your current directory should have package.json file. for example based on the project you uploaded, you should be inside diplom folder and then run npm install.

Related

How does NPM resolve & run scripts from package-json?

For curiosity's sake, I want to create a folder in node_modules and be able to run it as a script in package.json's "scripts", but I have not been able to find out how to.
I've noticed with other package.json scripts like "react-scripts" that they wont work in the command line, but will when NPM runs them. How does npm resolve scripts?
Does it have to be a legit package for NPM to run it? (Like, will it check against the NPM registry for if that package exists, or contains scripts?)
If a module has a ["bin" entry in its package.json]1, then npm will put the executable script specified by that "bin" entry into a .bin folder in node_modules.
When running a script with npm run, npm will put that node_modules/.bin directory first in the PATH so they are found with npm run but not when run directly from the shell.

Why is Heroku telling me it cannot find a package.json in my module when I do a heroku push

I created my own npm package from a fork of react-coverflow. It appears to be working fine in my app locally using it this way: "npm install react-coverflow-mod" --save.
I can run my app using "run with debug (F5)" in VsCode and npm start on the client folder to start the React front end.
Then I do an npm run build on the client folder, and it works just fine.
When I do a heroku push it fails everytime with this error:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "../../react-coverflow-mod"
as it does not contain a package.json file.
1. I know there is a package.json in the module because I can install it via "npm install react-coverflow-mod": https://www.npmjs.com/package/react-coverflow-mod
2. The installed module has a package.json file in it
3. My github repo has a package.json in it: https://github.com/leroyvaughan/react-coverflow
I'm not sure how I can fix this. Do I need a package.json to go into the /Dist folder? What is wrong here with Heroku.
It seams like heroku try to install a package from a relative path instead of the published name. That would perfectly explain why you can run locally but not on a production environment.
Open your project and search for the exact string displayed in your log: "../../react-coverflow-mod" and you should be able to find quickly where it is.
If you run on a unix system (don't know about windows) you can do a search using grep:
grep -rnw '/path/to/somewhere/' -e '../../react-coverflow-mod'
Make sure it includes your root folder which contain package.json, and might we wise to ignore node_modules which is always massive.

npm errors and warnings in terminal

can anybody tells me what are those errors about and how to fix them?
Everytime i try to install something in node with npm these errors show up in terminalenter image description here
ENOENT stands for basically "Error, No Entry". this means it was looking for the package.json file and it couldn't find it.The fields mentioned below are also not found because they are a part of the package.json file
so create a package.json file in the current current directory using
npm init
and add the required content in the required fields
i would also recommend you to install the modules locally into the directory of the particular project using
npm install express --save
Hope my answer helps,
cheers
The error you are facing is because you do not have package.json file. Npm installs the package in a node_modules/ subfolder, but warns you that there is no package.json file. If you want to manage localy installed npm packages you should create a package.json file. Start by creating an empty folder:
$ mkdir myapp
$ cd myapp
and then create a new package.json executing
$ npm init
Answer (or skip) all questions and at the end a brand new package.json will be created.
You can get more information from the Getting started articles in npm documentation: Working with package.json

How do I get spectacle-code-slide working on Windows?

I have installed Node on a Windows 10 machine. Then did npm install spectacle from the node command prompt. Finally downloaded the spectacle-code-slide zip file. Moved into the folder, did npm install and npm start. I get the following:
npm ERR: missing script: start.
Obviously, I am missing something. What is it? Note: I am a complete noob!
Edit: I tried the process outlined here without success.
This error means that you don't have start script in your package.json. Read about scripts here.
When you run npm instal spectacle you install spectacle as a package into node_modules folder. So you don't have any scripts in your package.json except those you add there yourself.
I've actually never used spectacle, but I suppose you better use their spectacle-boilerplate (instead of doing npm instal spectacle). You need to clone (via git) or download that repository locally. And then you will have their package.json with start script in it.

Install NodeJS package locally

When i try to install package on my local directory using npm install connect,but it just keep pop up some warning about
no such file or directory, open '/Users/felixfong/package.json'
But i don't not want to install package at my computer directory,i want to install at my local web app directory
Are you sure you are inside your local web app directory when you run the npm install connect command?
cd app-directory/
npm install connect
Also ensure that a package.json file is also present in the app-directory.
If it isn't present, you can use npm init command to create the package.json file interactively.
You have to go inside your project directory using
Then you can check package.json.
If package.json file is not there then initialize npm using the following command:
npm init
Then your can install the package using the following command:
npm install connect
'npm install connect' does not save the connect npm package in package.json file.
For saving the package into package.json file you have to givt --save option like:
npm install connect --save
Make sure that you are in web app's directory. Current path can be checked via command pwd in Linux and cd in windows. Navigate to your web app directory if you are somewhere else. Check existence of package.json by listing the content of the folder. ls and dir can be used for ubuntu and windows respectively for listing content. Commands for ubuntu are as below:
pwd
cd your-path/
ls
Now Initialize npm in your web app directory if package.json is not already existing there.
npm init
This will ask some information like:
name of the app,
its version,
description,
entry point,
test command,
git repo,
keywords,
author and
license (if any)
You can select default values by leaving the fields empty if you aren't sure or confused about any field. Combining this information as json, npm will create a file named package.json
Just run the desired command now after initialization of npm or if its already initialized:
npm install connect

Resources