If I install ESLint globally I can use it, but if I uninstall the global ESLint and install it only inside the project folder with:
npm install eslint --save-dev
And then run eslint -v, it says command not found.
Do I need to install ESLint also globally if I want to use it only in my project?
Installing it locally will install it under the node_modules directory, which will not be in the PATH your system searches for executables.
Run it with npx, which is distributed with recent versions of npm.
npx eslint -v
To use it locally, ensure you have eslint installed:
npm install --save-dev eslint
The in your project folder run:
./node_modules/.bin/eslint --init
You only installed it locally, so you can only run it via ./node_modules/.bin/eslint -v.
To install it globally do it like this: npm install --global esint --save-dev. Maybe you need sudo/root rights.
for me it works with npx. so, commands will be something below (may be it will work for you with npm)
npx eslint --fix
npx eslint . --ext .js,.jsx,.ts,.tsx
npx eslint --fix . --ext .js,.jsx,.ts,.tsx
Related
I try to install node packeges with nmp. When i run, it says:
up to date, audited 356 packages in 7s
found 0 vulnerabilities
I see it as a dependency in my package-json like this:
"dependencies": {
"express": "*",
"nodemon": "*"
}
but there is no node_modules was installed..
Hope someone can help.
edit: I tried the commands given in the answers but it didn't work. still same
ss from editor
These commands solve the same problem and have a look at the attached links.
https://github.com/npm/npm/issues/17282
Can't install anything using "npm install"
npm install -g npm
npm cache clean
npm update
npm install
There are a few fixes to this issue.
The first one is to install the dependencies manually, as so.
$ npm install -s express nodemon
The command should install express and nodemon at the latest versions.
The second option is to run a few commands, as so (in the order given).
$ npm install -g npm
$ npm cache clean --force
$ npm update
$ npm install
Basically, these are what the commands do (from 1-4).
This installs npm from npm (sounds weird, but there is an npm package).
This command forcefully cleans out the cache of npm.
As you can tell, npm update updates npm!
Finally, this command should be run in a directory where there is a package.json file. This installs all the dependencies listed in package.json.
Don't type out the $ in the terminal examples!
enter code here I've created a react project, using command : npm create-react-app
Installed
node-sass: "^5.0.0"
react: "^17.0.1"
Then I tried to import blank index.scss file to index.js componenet
Screenshot Code of Index.js
[Code of Index.js][1]
Screenshot of Localhost
image of localhost having the description of error
Special Note :
After getting this I Have uninstall node-sass and installed again with version4+. Please find below screenshot of cmd.
npm uninstall node-sass
npm install node-sass#4.14.1
cmd screenshot
Please uninstall it an then install the last version of 4:
npm uninstall node-sass
npm install node-sass#4.x
npm uninstall node-sass
npm install node-sass#4.14.1
Or, if using yarn (default in newer CRA versions)
yarn remove node-sass
yarn add node-sass#4.14.1
Do not go back. That’s quitting.
rm -rf ./node_modules ./package-lock.json
Then
npm i
Done ✅
Try installing sass instead of node-sass.
yarn remove node-sass
yarn add sass
I have this in my package.json
"devDependencies": {
"chromedriver": "^2.37.0",
"geckodriver": "^1.11.0",
"nightwatch": "^0.9.20",
"selenium-server": "^3.11.0"
},
"scripts": {
"e2e": "nightwatch -c tests/nightwatch.conf.js -e chrome"
}
and I'm able to execute npm run e2e
But in my terminal when I do node nightwatch -c tests/nightwatch.conf.js -e chrome I got this error
Error: Cannot find module 'C:\Users\James\Documents\sample_project\nightwatch'
Just curious, what's the problem? I doubt I know how npm and node work now.
When you do 'node nightwatch' it should go into node_modules folder and look for nightwatch, but instead its looking in the root directory.
You could cut the nightwatch folder in node_modules and move it to the same directory as package.json. Give it a try!
Is nightwatch module installed globally? If not, then install this module globally first using npm install nightwatch -g. As you are using this module inside CLI command, hence this must be installed globally in the system.
Sometime there might be issue with npm cache. Try to clean up the npm cache using:
npm cache verify
npm cache clean --force
npm cache clear --force
Then you can run npm install and npm install nightwatch -g again, just to make sure all modules are installed.
Moreover, you can try to use --verbose in your command like:
node nightwatch.js --verbose
And see the output, may be this help to debug the issue.
I tried use tslint --fix but get bash: tslint: command not found....
I installed tslint using command: yarn global add tslint typescript.
My machine use Centos 7.
I've run into the same problem recently. Yarn output says it added "tslint" binary, but it's lying. To actually install it you need to run Yarn as root, so:
sudo yarn global add tslint typescript
I needed to delete the /node_modules folder and run npm install and it was fixed again
I was wondering if makes any sense to use in the npm install command the --global and the --save parameters all together. For example:
npm install gulp -g -s
As far as I know there is no package.json in the npm system folder, so I suppose the answer is "no", but I want to clear all doubt.
The npm install command does not support installing a module both globally and save it to the package.json in one step.
There is, however, a way to install a module globally indirectly. The package.json supports a preinstall property like so:
"scripts": {
"preinstall": "npm install -g gulp"
}
As soon as you execute npm install, gulp will be installed globally. Please note that your current user then needs permission to write to your global node module directory.