yarn start - command "start" not found - json

yarn start leads to an error saying command "start" not found. In my package.json file there is no script's tag, could that be the issue. Please suggest a fix.
I am trying to install react, the commands being:
npm install -g create-react-app#1.5.2
create-react-app confusion
yarn start
cmd error:
command prompt
package.json:
"name": "confusion",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
}
}

npm uninstall -g create-react-app // uninstall the old create-react-app version (in your case, v1.5.2) to make sure npx uses the latest version in Step 2
npx create-react-app my-react-app-name // npx installs the latest version of create-react-app without requiring a global install. it is included with npm, so no need to install it. if you wish, replace my-react-app-name with whatever you want your project to be called
cd my-react-app-name
yarn start

Related

How should I start yarn server?

PS C:\Users\Mahima\OneDrive\Desktop\StackOverflow-clone> yarn start
yarn run v1.22.4
warning package.json: No license field
error Command "start" not found.
I have installed all the required dependencies along with yarn still it is showing the error "warning package.json: No license field"
The quickest solution is to add following to your package.json file
{
"private": true
}

babel-node is not recognized as an internal or external command, operable program or batch file

When I try to run a JS file by babel command it is showing:
"babel-node is not recognized as an internal or external command, operable program or batch file".
I had created 1.js file in this written "console.log("hello world")";
and tried to run with babel-node command but it is showing the above-mentioned error.
you can try install babel's global version
npm install -g babel-cli
Tried many suggestions and finally, I had to explicitly provide the absolute path to babel-node to get it working in scripts definition section in package.json file.
"start": "nodemon --exec ./node_modules/.bin/babel-node src/index.js"
node - v15.5.1
nodemon - v2.0.7
#babel/node - v7.12.10
Make sure that you have got the babel module so that it can be used.
For example by using npm install babel-cli to get a node_modules folder.
Then you can find the runnable in node_module/.bin.
a combination of above solutions worked for me:
npm install #babel/node
npm install #babel/cli
npm install #babel/core
and then I ran npm start and it worked.
Adding npx to the command might help, so exact binary will be executed
nodemon --exec npx babel-node src/index.js
For me the issue was solved by installing 'babel-node' globally by running this command:
npm install #babel/node -g
If your project is based on babel 7, you should run this
npm install #babel/cli #babel/core
install #babel/node , i came across the same problem and by installing this solved my problem
To intall babel packages worked for me
npm i #babel/cli #babel/core #babel/node #babel/preset-env --save-dev
"nodemon --exec ./node_modules/.bin/babel-node src/index.js"
What is currently missing is part of #babel/node. Depending on your project dependency you can install:
npm install #babel/cli
npm install #babel/node
My issue solved by running this command
> npx babel-watch .
you can also use
"start": "babel-node backend/server.js"
For those who struggle making it work for node + nodemon, what helped me was:
Install these deps:
"#babel/cli": "^7.14.5",
"#babel/core": "^7.14.6",
"#babel/node": "^7.14.7",
"#babel/preset-env": "^7.14.7",
"nodemon": "^2.0.12"
You can leave path to babel-node to be relative.
"dev": "nodemon src/index.js --exec babel-node",
This fixed it for me:
npm ci
(npm clean install removes node modules and then installs them again)
After trying everything here, it still didn't work. Eventually I got it working by removing the folders containing the executable (which for me was node_modules/.bin/).
Before:
"scripts": {
"babel": "node_modules/.bin/babel src/index.js -o dist/assets/bundle.js"
}
After:
"scripts": {
"babel": "babel src/index.js -o dist/assets/bundle.js"
}
yes i also get this error
it was resolved do check 👇
$ npm run dev
server#1.0.0 dev
nodemon --exec babel-node index
[nodemon] 2.0.15
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: js,mjs,json
[nodemon] starting babel-node index.js
'babel-node' is not recognized as an internal or external command,
operable program or batch file.
[nodemon] app crashed - waiting for file changes before starting...
after that I
install nodemon globally then it was resolved.
$ npm install -g nodemon
added 2 packages, removed 85 packages, changed 30 packages, and audited 33 packages in 9s
3 packages are looking for funding
run npm fund for details
found 0 vulnerabilities
result was ✅🔥
👇👍✅
$ npm run dev
server#1.0.0 dev
nodemon --exec babel-node index
[nodemon] 2.0.19
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: js,mjs,json
[nodemon] starting babel-node index.js
Server is runing 🔥
Confirm that you have these dependencies at a minimum in your package.json:
"dependencies": {
"#babel/core": "7.13.10",
"#babel/node": "7.13.12",
"#babel/preset-env": "7.13.12",
..
},
"devDependencies": {
"nodemon": "2.0.7",
...
}
Then check what script you are running. If you see the problem when running npm run dev and you have something like:
"scripts": {
"dev": "nodemon --exec babel-node ./src/server.js",
..
},
Update your scripts to the following (assuming you don't already have a "start"):
"scripts": {
"start": "babel-node ./src/server.js",
"dev": "nodemon --exec npm start",
...
},
Basically, nodeman is used during dev to hot reload code changes. babel-node itself runs the server, but the issue being faced occurs when installed package is not detected by nodeman.
Although installing #babel/cli globally, might appear to resolve the issue, it's not needed (and frowned upon: https://babeljs.io/docs/en/babel-cli)

How do I create a package.json file?

In Mac Terminal:
package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.
Please include the following file with any support request:
npm ERR! /Users/stickupartist/portfolio/npm-debug.log
stickup-artists-macbook-pro:portfolio stickupartist$ npm init
This utility will walk you through creating a package.json file.
What utility is being referred to?
And next:
Use `npm install <pkg> --save` afterwards to install a package
and
save it as a dependency in the package.json file.
Name: (portfolio)
I type:
npm install <portfolio> --save
And the terminal prints out:
Sorry, name can only contain URL-friendly characters.
What am I doing wrong with my naming? I'm working on my local machine with Meteor, on Mac OS X.
To create the package.json file, you can run npm init (and go through its options) or manually create the file based on these rules.
Here's a simple package.json file:
{
"name": "my-cool-app",
"version": "1.0.0",
"description": "This is my cool app",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
},
"author": "Me",
"license": "MIT",
"dependencies": {
"jquery": "1.1.1",
}
}
Now, as far as the error:
Sorry, name can only contain URL-friendly characters.
It means that the package name doesn't meet one of the naming rules, mainly:
package name must not contain any non-url-safe characters (since name ends up being part of a URL)
This is most likely happening because you wrapped your package name in <>.
<> means it is a placeholder for a value. When actually typing it in, you should overwrite it (and anything it wraps) with some appropriate value, in this case a valid package name.
It is how you would define an npm install command, not use it:
Definition:
npm install <package_name_goes_here>
Usage
npm install portfolio
Use: npm init -y
Then install your packages.
That worked for me when I had the same problem.
See nem035's answer to create package.json (just npm init).
For your other problem: in npm install <pkg> --save refers to the name of a package. You can install the package with its name, without brackets. For example, npm install portfolio --save
Log out of the session. Then re-login and try npm install -y. This has worked for me.

devDependencies ignored in npm?

I am the author of two npm modules, both with devDependencies.
The first one is simpleDbLayer. Install it:
npm install simpledblayer
The downloaded package.js file has devDependencies matching what is in the git repository:
//...
"devDependencies": {
"simpleschema": "0.3.x"
},
//...
Unfortunately, nodeunit test.js will fail because simpleschema wasn't installed (as it should have been). From the manual:
By default, npm install will install all modules listed as dependencies. With the --production flag, npm will not install modules listed in devDependencies
Even weirder (and this is the really strange issue I am most affected by) is my other module, simpledblayer-mongo:
npm install simpledblayer-mongo
In he installed package.js file, I have:
"devDependencies": {},
Which doesn't match what was actually published, which contains:
"devDependencies": {
"simpleschema": "0.3.x",
"simpleschema-mongo": "0.3.x"
},
Needless to say simpleschema and simpleschema-mongo is not installed.
Am I missing something?
Yes, by default it will install the devDependencies but only for your project (devDependencies in your package.json), not for modules in the npm repository.
If you want the devDependencies of your dependencies, force it by passing --dev to the npm command:
npm install simpledblayer --dev
Also, when you have the environment variable NODE_ENV set to production, it won't install the devDependencies either (not even the ones in your package.json).

How can I use npm to download and update modules from a list in a package.json file?

I am using windows with node.js downloaded. I created this package.json.
{
"version": "0.0.0",
"name": "abc",
"devDependencies": {
"del": "^1.1.0",
"gulp-uglify": "^1.0.2",
"gulp-sourcemaps": "^1.2.8",
"gulp-typescript": "^2.3.0",
"less-plugin-clean-css": "^1.2.0",
"typescript": "^1.3.0"
}
}
Is there an npm command line task that I can run to fetch all of these modules and install / update these into a node_modules directory? If needed I can change my package.json so I would appreciate advice on that also.
Thanks
Doesn't
"npm install"
do the trick? (from your folder that contains the package.json)
It works on linux, haven't a window machine to try right now
try
npm install
npm update --save-dev
If you already had the package.json file (with dependencies entries), then you can use npm install to install dependencies on node_modules directory.
npm install
or you can update the dependencies to use latest version (will override currently installed dependencies on node_modules directory) using npm update
npm update
You don't have to put the dependency you want manually to package.json, you just use command npm install {package-name} with additional option like --save / --save-dev / --save-optional.
In example you want to add dependency of node-q to your application, you can do this:
npm install q --save
Juggling into different option --save-prefixed value will act as follows,
--save will add dependency to dependencies attribute of your package.json, it will be installed mainly for your application
--save-dev will add dependency to devDependencies attribute of your package.json, it will be installed for development phase of your application (usually it is testing dependencies)
--save-optional will installed for optional (nice to have) dependencies. I rarely used it for my applications or libraries anyway.
Don't forget you MUST run commands from your application directory (the one that node_modules directory resides).