when run nodemon in angular ts getting this error? - node.js

The problem is when I execute the npm run dev command I get the following error
node_modules is not recognized as an internal or external command
This is how the packages.json script looks like:

Try this:
"compile":"./node_modules/.bin/tsc && node server.js"
Might be a path issue, your command line thinks that "node_modules" is a command.

Related

Vite: why am I getting vite:command not found error?

I have installed vite in my vue.js app. I start the app by typing npm run dev in the main project directory. In the package.json this is defined as:
"dev": "vite"
but if I try do run this command (or eg. vite build) 'manually' from main directory, I get an error:
bash: vite: command not found
I also figured out that when I set a new script:
"build": "vite build"
I can run this command also, although, again, running it manually will result in error as above.
This seems quite illogical to me. Can anybody explain how is it possible?
If you didn't install vite globally (using npm install -g), then the vite command will be in node_modules/.bin in your main directory. The npm run command temporarily adds that folder to your PATH so it can execute that command. Try running ./node_modules/.bin/vite to run it without npm.

"npm run" commands fail on Windows

I am using Windows PowerShell ISE with administrator privileges. My project uses webpack, which is installed as a local dependency with npm. I have a "script" defined in package.json:
"build": "webpack --progress --config resources/assets/build/webpack.config.js",
When I execute npm run build I get the error message 'webpack' is not recognized as an internal or external command, but if I copy the webpack command and execute that it works fine. I'm not going to list my whole system PATH here, but it includes .\node_modules\.bin at the beginning. Clearly Windows has no problem finding webpack but Node for some reason can't.
I tried running npm run build in a privilege-less Command Line, no difference. I upgraded to the latest versions of Node and npm (13.0.1 and 6.12.1, respectively), to no avail. I even tried prefixing the command in package.json with ./node_modules/.bin/ but that didn't work.
Please don't suggest that I install webpack globally as that is not a real solution. Node is giving me this error with all locally-installed commands, not just webpack. I should be able to run commands locally through npm.
if you're using a recent version of npm, you can try
npx webpack ....
alternatively, you can install webpack locally and specify the exact path
node_modules/webpack/bin/webpack.js ....
In the end, I had to bite the bullet and install webpack globally.

How to run kss package? Script not recognized by node

I want to create a CSS documentation and installed KSS Doc: https://github.com/kneath/kss
But the script (kss --css ../styles/style.css --source styles) doesn't work as written in the doc. I don't use Webpack or any fremework, so only have a package.json file.
Here is how to use KSS: https://github.com/kss-node/kss-node
For example, $ kss --demo doesn't work.
Should i add script in my package.json file, and if yes, what?
Or do I need Webpack?
I'm using node 10.15.3 and KSS is old too.
The error I get:
$ npm run kss --confignode_modules/kss/demo/kss-config.json
npm ERR! missing script: kss
I would like to be able to run the script, give the source and destination as explained in the doc. Thanks.
You need to add a script to your package.json in order to run it:
{
...
"scripts": {
...
"kss": "node ./node_modules/kss/index.js" // `node` is required on Windows
}
...
}
and then run it like this:
npm run kss -- --config node_modules/kss/demo/kss-config.json
Not the additional -- after the script name. It tells npm that the following arguments need to be passed to the kss command itself and not to the npm run command.

Nodemon is not recognized as an internal command operable program or batch file

I was working with NodeJS, but due to some other issue I installed Windows again. Now I have installed nodemon gloabally and it also show version in C drive, but when I try to run project it gives me the error:
nodemon is not recognized as an internal command operable program or batch file
Run: $ npm install -g nodemon
Run: $ npm install --save-dev nodemon
Change package.json file as:
"scripts": {
"serve": "nodemon index.js"
}
Run: $ npm run serve
Make sure that you have nodemon dependency in package.json file in your current project. If you don't see it listed in this file run npm i nodemon --save
Once checked, you might execute nodemon by:
running script nodemon index.js (or whatever name your js file has)
running command npm run start (though you have to update scripts in your package.json file with new script "start": "nodemon index.js")
running command nodemon, but in this case you have to have index.js file in your current project as well, as by default nodemon will try to find and execute index.js file.
I installed it as "npm install -g nodemon".
That worked for me.
it was Loading error and was completely loaded after i restart System so that works
In My Windows this is Work :
npm install -g nodemon
Open your folder that you want to run nodemon, ex in my picture:
https://i.stack.imgur.com/fUTnV.jpg
in Terminal write : Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
in Terminal write : nodemon
You write install instead of init
Run npm install nodemon
first try this: npm install -g nodemon if this not work in case of mine
try yarn add nodemon it will work

nodemon bin/www works, nodemon app doesn't and throws error

When I run nodemon bin/www inside my app, it works perfectly, when I try to run nodemon app, it throws this error:
'\"node .\bin\www\"' is not recognized as an internal or external command,
operable program or batch file.
I believe this happened after I received a notification from nodemon today to run npm install -g nodemon to update the nodemon library, after the installation, I got this error:
Please try running this command again as root/Administrator.
I tried to run the cmd as administrator, again, the same problem. Any solution?
step 1: run npm install -g nodemon
step 2: verify installation npm list -g nodemon
Now you can run the app by two ways
nodemon ./server.js localhost 8080
Any output from this script is prefixed with [nodemon], otherwise all output from your application, errors included, will be echoed out as expected.
2nd just type nodemon
If you have a package.json file for your app, you can omit the main script entirely and nodemon will read the package.json for the main property and use that value as the app.
With a local installation, nodemon will not be available in your system path. Instead, the local installation of nodemon can be run by calling it from within an npm script (such as npm start) or using npx nodemon.
or
It turns out that you don’t have to run the command again as
Administrator, and doing so won’t fix the problem. Try
npm cache clean first.
check this for more detail
https://www.npmjs.com/package/fixmynode
command against as root administrator
how-to-fix-node-js-npm-permission-problems
I think you are getting this error because you did not install it as a global module. Try to install nodemon using the -g flag.
$ npm install -g nodemon
Install the nodemon module globally using
npm install -g nodemon
Also install the module in the package in your project where the package json is present using
npm install nodemon -save
Check if the nodemon is present in the json list.
Now run the js file using any of the following
nodemon
nodemon app.js
nodemon app
Use the following command line in an windows environment (1st cd to your apps root directory):
nodemon ./bin/www

Resources