I have an angular project (really just the docs tutorial) and I want to include the node-mysql module in my project- doesn't have to be installed globally.
Not sure I understand how this works but I thought all I have to do was add this module to package.json as a dependency and run npm install, but I get an error:
PS> cat .\package.json
{
"version": "0.0.0",
"private": true,
"name": "angular-phonecat",
...
"dependencies": {
"node-mysql": ">=2.5.0"
},
"devDependencies": {
"karma": "^0.12.16",
...
The error:
PS> npm install
npm WARN package.json karma-chrome-launcher#0.1.7 No README data
npm ERR! notarget No compatible version found: node-mysql#'>=2.5.0'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.1.1","0.1.2","0.1.3","0.1.4","0.1.5","0.1.6","0.1.7","0.1.8","0.1.9","0.2.0","0.2.1","0.2.2","0.2.3","0.2.4","0.2.5","0.2.6","0.2.7","0.2.8","0.2.9","0.3.0","0.3.1","0.3.2","0.3.3","0.3.4","0.3.5","0.3.6","0.3.7","0.3.8","0.3.9","0.4.0","0.4.1"]
npm ERR! notarget
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\testangular\ticketsys\angular-phonecat
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ETARGET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\testangular\ticketsys\angular-phonecat\npm-debug.log
npm ERR! not ok code 0
How can I include this dependency in my project?
Node-mysql version >2.5 is not out yet. Node-mysql is on version 0.4.1. I suspect you are looking for just the regular mysql npm module. Mysql on npm is on version 2.5.4.
Try using this instead:
"mysql": ">=2.5.0"
If you go to this page: https://github.com/felixge/node-mysql . They say in the install instructions to use npm install mysql. This might be a bit confusing since their github page is node-mysql.
Alternatively instead of adding this manually to the dependency you could go ahead and do the following:
npm install mysql --save
This will only install the most up to date one locally (Not globally, if you wanted to install it globally you could add the -g flag, but since you don't need that dont!).
As mentioned in other answers, npm is not recognizing the version you have specified. I would recommend removing that line from your package.json and instead running a single command:
npm install --save mysql
This will install the dependency locally AND add the line to your package.json(that's what the --save flag does). This automatically defaults to the most recent stable version of node-mysql.
In general, the only time you'll want to specify an actual version in your package.json is if a library patched over some features you actually wanted, in which case you could specify a version so that the necessary features are always there. So definitely start using the --save flag when you can. It's super useful. Best of luck!
Related
although I am good in react but when I was tiring to install react version 1.2.5, I was getting this error again and again for running
npm i -g create-react-app#1.2.5
Output
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global`
instead.
npm ERR! code ETARGET
npm ERR! notarget No matching version found for create-react-app#1.2.5.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sibri\AppData\Local\npm-cache\_logs\2022-06-14T07_21_55_731Z-
debug-0.log
Anyone got any idea where I went wrong
As I can see in the returned error you should use --location=global instead of -g flag.
npm ERR! code ETARGET
npm ERR! notarget No matching version found for tagcloud#^2.0.2.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
But "TagCloud" is in package.json.
Maybe the best solution is, if the npm install command doesn't work, to run npm i -S TagCloud#2.0.2 if you need to use that specific version, otherwise, just run npm i -S TagCloud.
My app uses sass, not node-sass. node-sass is nowhere in my package-lock.json.
I'm currently using npm 6 and everything is working fine and has been for years.
When I try to npm install with npm 7, it fails with the below error.
What's going on? Maybe node-sass is a dev dependency of something else and being built?
npm ERR! npm ERR! code 1
npm ERR! npm ERR! path /Users/john/.npm/_cacache/tmp/git-clonenbaf30/node_modules/node-sass
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c node scripts/build.js
npm ERR! npm ERR! Building: /opt/local/bin/node /Users/john/.npm/_cacache/tmp/git-clonenbaf30/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! npm ERR! c++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DLIBSASS_VERSION="3.3.6"' -I/Users/john/.node-gyp/14.18.3/include/node -I/Users/john/.node-gyp/14.18.3/src -I/Users/john/.node-gyp/14.18.3/deps/uv/include -I/Users/john/.node-gyp/14.18.3/deps/v8/include -I../src/libsass/include -O3 -gdwarf-2 -mmacosx-version-min=10.7 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=c++11 -stdlib=libc++ -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/libsass/src/libsass/src/eval.o.d.raw -c -o Release/obj.target/libsass/src/libsass/src/eval.o ../src/libsass/src/eval.cpp
### above line repeated many times
npm ERR! npm ERR!
You might be using a version of Node or npm that are not compatible with the version of node-sass that is being pulled. node-sass publishes this table that shows the range of supported versions for any toolchain version. If one of your dependencies is pulling node-sass, you could force your desired version by explicitly specifying node-sass as a direct dependency. You could also consider upgrading Node or npm as an alternative.
To see what would happen I tried npm install --package-lock-only, and it succeeded. I could then see the dependency tree. node_modules/sass-loader has node-sass as a peer dependency.
npm7 installs peer dependencies by default and doesn't allow getting into an ambiguous state. (more info: https://stackoverflow.com/a/22004559/168143 )
So, that's why this was happening. I don't know if I wasn't reading the stack trace well enough or if there is some other standard way for me to have figured out what had the dependencies. I'll leave this question without an accepted answer just in case someone has a smarter way to diagnose this sort of thing.
My Goal:wanna initialize Vue.js project by running commands vue init webpack myproject
Expected Result: install all the dependencies with no fatal error, AND would be able to start running the project by npm dev run,and run project on http://localhost:8080
ACTUAL Result:
# Installing project dependencies ...
# ========================
npm WARN deprecated extract-text-webpack-plugin#3.0.2: Deprecated. Please use https://gi
thub.com/webpack-contrib/mini-css-extract-plugin
npm WARN deprecated browserslist#2.11.3: Browserslist 2 could fail on reading Browsersli
st >3.0 config used in other tools.
npm WARN deprecated bfj-node4#5.3.1: Switch to the `bfj` package for fixes and new featu
res!
npm WARN deprecated core-js#2.6.11: core-js#<3 is no longer maintained and not recommend
ed for usage due to the number of issues. Please, upgrade your dependencies to the actua
l version of core-js#3.
npm WARN deprecated browserslist#1.7.7: Browserslist 2 could fail on reading Browserslis
t >3.0 config used in other tools.
npm WARN deprecated circular-json#0.3.3: CircularJSON is in maintenance only, flatted is
its successor.
npm ERR! Unexpected end of JSON input while parsing near '...,"dist":{"shasum":"1e'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-02-12T06_01_01_
430Z-debug.log
Running eslint --fix to comply with chosen preset rules...
# ========================
> travel#1.0.0 lint F:\SourceCode\Travel-master\Travel
> eslint --ext .js,.vue src "--fix"
Oops! Something went wrong! :(
ESLint: 6.8.0.
ESLint couldn't find the plugin "eslint-plugin-vue".
(The package "eslint-plugin-vue" was not found when loaded as a Node module from the dir
ectory "F:\SourceCode\Travel-master\Travel".)
It's likely that the plugin isn't installed correctly. Try reinstalling by running the f
ollowing:
npm install eslint-plugin-vue#latest --save-dev
The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js".
If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslin
t to chat with the team.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! travel#1.0.0 lint: `eslint --ext .js,.vue src "--fix"`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the travel#1.0.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging out
put above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-02-12T06_01_04_
492Z-debug.log
# Project initialization finished!
# ========================
To get started:
cd Travel
npm run dev
Documentation can be found at https://vuejs-templates.github.io/webpack
What I've tried
run the commands like above mentioned npm install eslint-plugin-vue#latest --save-dev,then comes another issue like below:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for eslint-plugin-vue#lastest.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-02-12T06_09_11_
766Z-debug.log
even I tried the npm install webpack -dev-server -g,then comes another issue like below:
C:\Program Files\nodejs\webpack -> C:\Program Files\nodejs\node_modules\webpack\bin\webp
ack.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.11 (node_modules\webpack\no
de_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.11:
wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ webpack#4.41.6
added 322 packages from 197 contributors in 255.517s
I had the same problem when coding my app (MEVN) and using the command vue init webpack client.
So I did a bit of research notably on npm to see what was wrong and found this: https://www.npmjs.com/package/vue-cli so apparently you can't use this command anymore.
So if you wish to use the vue cli you need to install it trough npm install -g #vue/cli and then run vue create <dir name>
For further information you can look into the documentation: https://www.npmjs.com/package/#vue/cli with the documentation on the vuejs website: https://cli.vuejs.org/
Hope this helps and have fun coding
I am trying to run npm install on my terminal as part of the setup for angular-phonecat as per the instructions on https://docs.angularjs.org/tutorial
When I run the command I am getting issues with deprecated modules and errors when reaching the bower install section.
Does anybody know how I can update the deprecated modules to avoid the warnings and how I can fix the bower errors?
Here is the output I am receiving:
npm WARN deprecated tough-cookie#2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated minimatch#0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
-
> fsevents#1.0.14 install /Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/karma/node_modules/chokidar/node_modules/fsevents
> node-pre-gyp install --fallback-to-build
[fsevents] Success: "/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/karma/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/node-v46-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
> angular-phonecat#0.0.0 postinstall /Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat
> bower install
bower EACCES EACCES: permission denied, unlink '/Users/Eamon/.cache/bower/registry/bower.herokuapp.com/lookup/jquery_d223e'
Stack trace:
Error: EACCES: permission denied, unlink '/Users/Eamon/.cache/bower/registry/bower.herokuapp.com/lookup/jquery_d223e'
at Error (native)
Console trace:
Error
at StandardRenderer.error (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/renderers/StandardRenderer.js:81:37)
at Logger.<anonymous> (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/bin/bower.js:110:26)
at emitOne (events.js:77:13)
at Logger.emit (events.js:169:7)
at Logger.emit (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/node_modules/bower-logger/lib/Logger.js:29:39)
at /Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/commands/index.js:48:20
at _rejected (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/node_modules/q/q.js:844:24)
at /Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/node_modules/q/q.js:870:30
at Promise.when (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/node_modules/q/q.js:1122:31)
at Promise.promise.promiseDispatch (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/node_modules/q/q.js:788:41)
System info:
Bower version: 1.7.9
Node version: 4.4.0
OS: Darwin 15.6.0 x64
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.4.0
npm ERR! npm v2.14.20
npm ERR! code ELIFECYCLE
npm ERR! angular-phonecat#0.0.0 postinstall: `bower install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-phonecat#0.0.0 postinstall script 'bower install'.
npm ERR! This is most likely a problem with the angular-phonecat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! bower install
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular-phonecat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls angular-phonecat
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/npm-debug.log
I have tried searching on other posts with similar issues but none of these have helped me find a solution:
error when npm install
Got an error while running "npm install" on angular-phonecat directory
Cannot npm install for angular-phonecat tutorial : Cannot find module 'update-notifier'
I have also tried running sudo npm install with the same issue. I have a feeling the bower install issues are due to the setup of the bower cache looking at the error output but I am not 100% certain.
Has anyone encountered similar issues when setting up the installation for angular-phonecat?
Any help would be greatly welcomed.
Many Thanks,
Eamon
ISSUE: You (the user) don't have the right set of permissions for the directory.
The instant way out is to run the npm install using sudo, but this may give you the same error, or improper installation.
AND changing directory ownership is not a good option, a temporary patch. I am answering the question, as I feel I have a more elegant solution/suggestion to the problem. I came across same issues multiple times i.e. 'npm install -g #angular/cli'.
Uninstalled the package and executed the following commands (in the order mentioned) to have clean installation.
Solution/Suggestion: Change npm's Default Directory (from official docs)
Back-up your computer before moving forward.
(optional) In case you have a erroneous installation, first uninstall it:
npm uninstall <package-name> # use sudo if you used it while installation
npm cache verify # or, npm cache clean for npm version below 5.x.x
Make a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
Open or create a ~/.profile or ~/.bash_profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
Back on the command line, update your system variables, or restart the terminal:
source ~/.profile
(optional) Test: Download a package globally without using sudo.
npm install -g jshint
Having looked into this it appears that bower was having issues with permissions and was resolved by running the bower install separately using sudo:
sudo bower install --allow-root
However, you should not use sudo with bower. It is likely that if you have to then the ~/.cache has been set incorrectly either by installing using sudo or installing your first package via sudo. More info about this can be found here: http://www.competa.com/blog/2014/12/how-to-run-npm-without-sudo/
Instead you should rectify the ownership by running the following:
sudo chown -R $user ~/.npm
sudo chown -R $user ~/.config
To find your user you can simply run the following command on the command line:
$ whoami
If you want to open to a wider group you can also add a group to the chown command. To find out which group your user belongs to you can type the following command:
$ groups
To set the group at the same time as the user simply change the command to the following and replace $user and $group with your desired user and group:
sudo chown -R $user:$group ~/.npm
sudo chown -R $user:$group ~/.config
If you are seeing an issue like one of the below when running a bower install during your npm install:
EACCES: permission denied, open '/some/directory'
EACCES: permission denied, unlink '/some/directory'
You will need to change the permissions to the folder containing the file to be your user by doing:
sudo chown -R USER /some/directory
Just change the folder that the file is stored in, not the file itself. When you run npm install after this it will work if it needs to install any bower components that are having issues installing while using your current user and not using sudo.
Thanks,
Eamon