I have this problem that is not letting me debug my website.
You dont have a 'start' script defined in your "scripts" section.
You could use the defined 'dev' script (npm run dev) or rename it to 'start'.
"scripts": {
"start": "nodemon src/index.js"
}
Tipp: Use npm run to list all available npm sripts
Related
I've always used just npm and never yarn/webpack explicitly. I need to run the code from this repo:
https://github.com/looker-open-source/custom_visualizations_v2
Like a dev server or something to ensure it's serving the files properly but I don't see a "run" like npm run start. Does this just not exist with yarn? It feels like this code should work as is and I shouldn't have to add anything.
EDIT: I've now tried yarn run watch but it just seems to build the code again and not actually host anywhere
npm run somecommand just looks up in the "scripts" field of package.json for the key
somecommand and executes the value in the terminal.
So npm run start basically runs the start script from package.json
The same thing is done using yarn via simply yarn start
In the linked repo, there isn't a start script in the package.json, rather a watch script, so you should be able to run it with the below steps:
yarn to install dependencies after cloning the repo to local (similar to npm install)
yarn watch to start the webpack server (analogous to npm run watch)
Edit:
Turns out the watch command is just setting up webpack to watch for changes and recompile the project every time there is a change.
To run a development server, you will need to add another script preferably with name start and use webpack-dev-server
So the package.json has entries like:
...
"watch": "webpack --config webpack.config.js --watch --progress",
"start": "webpack-dev-server --config webpack.config.js",
...
Then running yarn start should open a dev server at localhost:8080
Screenshot form VS code terminalnodemon : The term 'nodemon' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the
path is correct and try again.
I just meet that question.
First, you should make sure that you had installed nodemon in a global way (npm install -g nodemon), and make sure global package dir is in the environment variables.
Secondly, you should RESTART VScode if you are opening it now.
I spent lots of time to make sure the previous one, but it still fails, then when I restart VScode, everything is fine!
Try to install nodemon globally:
https://github.com/remy/nodemon
npm install -g nodemon
and edit Your package.json for example like that:
"scripts": {
"start": "node server",
"dev": "nodemon server"
},
then in terminal enter the command =>
npm run dev
It should works for You now ;-)
Good Luck and Best regards !
Below are some solutions
This is how you can install nodemon
npm install -g nodemon
after that you have to run this command: npm run dev
here dev is (script) server name like
{
"main": "app.js",
"scripts": {
"dev": "nodemon app.js"
},
}
after that if you are facing error like
" 'nodemon' is not recognized as an internal or external command,
operable program or batch file. "
Then after install nodemon globally write below command:
npm config get prefix
in output you will get PATH and then past this path in to the Environment Variables and it solved
Restart the terminal and run this command
nodemon run dev
I hope after that it will work properly :)
I just had to use npx instead of npm
for e.g. - npx nodemon <server.js>
Every time I try to run npm start or npm build I get an error saying unknown: Entry /mnt/c/Users/kabre/Desktop/18-forkify/index.html does not exist. I got told that Parcel might be automatically renaming my index.html. Not sure how to go on about fixing this since I'm just starting out learning Parcel/npm.
Try this:
Run npm init -y in your project
Install parcel in your project: npm install parcel-bundler --save-dev
Put this in your package.json:
"scripts": {
"start": "parcel ./index.html",
}
Run npm start after this.
And will running perfect.
Find more in https://parceljs.org/getting_started.html
Hi I use npm install jquery to install a jQuery for my project.but i find it is located in node_modules\jquery with many unwanted files.
but I just wana put node_modules\jquery\dist\jquery.min.js into static\jquery folder
what is the best and common way? copy and paste manually?
You can use npm to do this. In your package.json, add the following to the scripts key
...
"scripts": {
"build:jquery": "cp node_modules/jquery/dist/jquery.slim.min.js static/jquery/"
},
...
Then you can run: npm run build:jquery
You can add more build tasks to this section as you need them such as copying images and minifying scripts and css, then chain them together in a single command with npm-run-all:
$ npm install npm-run-all --save-dev
And...
...
"scripts": {
"build:jquery": "cp node_modules/jquery/dist/jquery.slim.min.js static/jquery/",
"build:images": "cp -R src/assets/images/ static/images/",
"build": "npm-run-all -p build:*"
},
...
Then run npm run build
npm is a great build tool and often bypasses the need for an additional build framework such as Gulp or Grunt. It can also handle file watchers and such to rebuild when things are modified automatically.
I am using npm start to start my MEAN stack application, but I would like to use the node-inspector to debug some Mongoose. I know I can start the node inspector with node-inspector, but what can I substitute node --debug app.js with to make npm start work in my case?
This is my MEAN stack directory structure:
HTML views/
Angular.js public/javascript/
Express.js routes/
Node.js app.js
Mongoose js models/, connected in app.js
Mongo db connected in app.js
For more information, this is my related question.
You may want to add a seperate debug script to package.json. That way you won't have to remember to revert npm start when you're finished debugging.
"scripts": {
"start": "node ./bin/www",
"debug": "node --debug ./bin/www"
}
Start with npm run:
$ npm run debug
In package.json modify the start run command:
"scripts": {
"start": "node --debug app.js"
}
I use it like this, I also set a variable and run the inspector in one command:
npm run debug
"scripts": {
"start": "set SOAPAPI=https://example.com/&&nodemon",
"debug": "start node-inspector --web-port=8081&&set SOAPAPI=https://example.com/&&nodemon --debug"
}
*nodemon is an utility wrapper for node, you can use node instead