I'm trying to learn react, so I have this sample code for the full-stack react voting app, and I am trying to get it to work but after running npm install followed by npm start I receive the following error when I run npm start can anyone help me with this issue:
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "server"
npm ERR! node v7.5.0
npm ERR! npm v4.3.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! voting_app#1.1.0 server: `live-server --public --
host=localhost --port=3000 --middleware=./disable-browser-cache.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the voting_app#1.1.0 server script 'live-server --
public --host=localhost --port=3000 --middleware=./disable-browser-
cache.js'.
npm ERR! Make sure you have the latest version of node.js and npm
installed.
npm ERR! If you do, this is most likely a problem with the voting_app
package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! live-server --public --host=localhost --port=3000 --
middleware=./disable-browser-cache.js
npm ERR! You can get information on how to open an issue for this
project with:
npm ERR! npm bugs voting_app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls voting_app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/ItsMeMrLi/.npm/_logs/2017-02-17T22_48_03_581Z-
debug.log
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.5.0
npm ERR! npm v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! voting_app#1.1.0 start: `npm run server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the voting_app#1.1.0 start script 'npm run server'.
npm ERR! Make sure you have the latest version of node.js and npm
installed.
npm ERR! If you do, this is most likely a problem with the voting_app
package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run server
npm ERR! You can get information on how to open an issue for this
project with:
npm ERR! npm bugs voting_app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls voting_app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/ItsMeMrLi/.npm/_logs/2017-02-17T22_48_03_655Z-
debug.log
Here is my package.json:
{
"name": "voting_app",
"version": "1.1.0",
"author": "Fullstack.io",
"scripts": {
"go": "open http://localhost:3000; npm run server",
"e2e": "nightwatch",
"test": "./node_modules/.bin/concurrently -k 'npm run server' 'npm
run e2e'",
"start": "npm run server",
"server": "live-server public --host=localhost --port=3000 --
middleware=./disable-browser-cache.js"
},
"private": true,
"devDependencies": {
"concurrently": "2.2.0",
"live-server": "git://github.com/acco/live-server.git"
},
"dependencies": {
"semantic-ui": "git://github.com/Semantic-Org/Semantic-
UI.git#27d58a01793b66318478fbc5b6676804d22d065d"
}
}
And finally my log file:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm#4.3.0
3 info using node#v7.5.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle voting_app#1.1.0~prestart: voting_app#1.1.0
6 silly lifecycle voting_app#1.1.0~prestart: no script for prestart, continuing
7 info lifecycle voting_app#1.1.0~start: voting_app#1.1.0
8 verbose lifecycle voting_app#1.1.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle voting_app#1.1.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/ItsMeMrLi/.rvm/gems/ruby-2.3.1/bin:/Users/ItsMeMrLi/.rvm/gems/ruby-2.3.1#global/bin:/Users/ItsMeMrLi/.rvm/rubies/ruby-2.3.1/bin:/Users/ItsMeMrLi/.cargo/bin:/usr/local/Cellar/smlnj/110.74/libexec/bin:/usr/local/bin:/Users/ItsMeMrLi/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Downloads/geckodriver:/usr/local/bin:/Users/ItsMeMrLi/.rvm/bin
10 verbose lifecycle voting_app#1.1.0~start: CWD: /Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app
11 silly lifecycle voting_app#1.1.0~start: Args: [ '-c', 'npm run server' ]
12 silly lifecycle voting_app#1.1.0~start: Returned: code: 1 signal: null
13 info lifecycle voting_app#1.1.0~start: Failed to exec start script
14 verbose stack Error: voting_app#1.1.0 start: `npm run server`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:192:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:192:7)
14 verbose stack at maybeClose (internal/child_process.js:890:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid voting_app#1.1.0
16 verbose cwd /Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app
17 error Darwin 16.4.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
19 error node v7.5.0
20 error npm v4.3.0
21 error code ELIFECYCLE
22 error errno 1
23 error voting_app#1.1.0 start: `npm run server`
23 error Exit status 1
24 error Failed at the voting_app#1.1.0 start script 'npm run server'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the voting_app package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error npm run server
24 error You can get information on how to open an issue for this project with:
24 error npm bugs voting_app
24 error Or if that isn't available, you can get their info via:
24 error npm owner ls voting_app
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]
Step 1: $ npm cache clean --force
Step 2: Delete node_modules by $ rm -rf node_modules (rmdir /S /Q node_modules in windows) folder or delete it manually by going into the directory and right-click > delete / move to trash. If you are not updating your packages you can delete the package-lock.json file too.
Step 3: npm install
To start again,
$ npm start
This worked for me. Hopes it works for you too.
PS: Still if it is there, kindly check the error it is displaying in red and act accordingly. This error is specific to node.js environment.
Cleaning Cache and Node_module are not enough.
Follow this steps:
npm cache clean --force
delete node_modules folder
delete package-lock.json file
npm install
It works for me like this.
I resolve this error running following code
npm cache clean
then delete node_modules directory from my project structure manually or with following command
rm -rf node_modules
After That install dependencies again using
npm install
first i ran:
npm run clean
(even though it came with errors)
Then i deleted the node_modules folder and ran
npm install
This seems to have solved the problem.
I was getting similar error messages on a 16.04 Ubuntu instance with DigitalOcean while running npm run build on an app made with create-react-app (link). I upgraded the instance from 512MB RAM to 1GB ($5/mo to $10/mo) and then the script was able to run.
I post this here to point out that you may get this error due to resource limitations, which I didn't really see explained elsewhere on issue pages and SO answers. And nothing I saw in the error logs pointed me in this direction.
Change access in node_modules directory
chmod -R a+rwx ./node_modules
This solution is for Windows users.
You can open the node.js installer and give the installer some time to compute space requirements and then click next and click remove. This will remove node.js from your computer and again reopen the installer and install it in this path - C:\Windows\System32
or
Cleaning Cache and Node_module will work.
Follow this steps:
npm cache clean --force
delete node_modules folder
delete package-lock.json file
npm install
Faced this exact problem,
for me it worked by deleting package-lock.json and re-running npm install
If that doesn't resolve it try
delete package-lock.json
npm cache clean --force
npm install
npm start
Delete node_modules and package-lock.json, and then run npm install. It worked perfectly here(run command below inside project root):
rm -rf node_modules && rm ./package-lock.json && npm install
I was getting this npm ERR! code ELIFECYCLE error while running a build. Clearing the cache and removing the package-lock.json files did not fix it.
In my case there was an Angular build running on a Docker image that was causing this. The root cause turned out to be running the build on Docker in MacOS, which runs the Docker inside a Linux VM, and has by default 2GB memory allocated.
Giving Docker more memory fixed this issue for me. Have to say, the error message could have been quite a bit more clear..
A helpful answer for me was Call retries were exceeded exception while ng build
workaround: Remove the lock file.
rm .\package-lock.json
source: https://github.com/mapbox/node-pre-gyp/issues/298 (floriantraber)
React Application: For me the issue was that after running npm install had some errors.
I've went with the recommendation npm audit fix. This operation broke my package.json and package-lock.json (changed version of packages and and structure of .json).
THE FIX WAS:
Delete node_modules
Run npm install
npm start
Hope this will be helpfull for someone.
npm install --unsafe-perm
worked for me. See https://docs.npmjs.com/. The --unsafe-perm parameter lets you run the scripts from the package instalation as root. The problem in my case was that some depandencies failed to install.
This solution fixed the error in Win10.
Please install globally npm install -g node-pre-gyp
i tried to solve this problem with this way
rm -rf node_modules && rm ./package-lock.json && npm install
But for me its not work.
I just restart my machine and its working perfectly.
Am Linux user ,Machine HP.
I recommend you update your node version to the latest node version recommended by your application or for short update your node version. I encountered this same problem using node version 11.1 but my application was recommending atleast version 10.x.x or 12.x.x
I tried all the suggested reply on this thread but non seemed to work for me untill only when i updated my node version to the recommended latest version .i.e. version 12.16.3 then my application ran.
I just wanted to do run npm run dist to apply some changes for SCSS files, but after hours of suffering, here's what worked for me:
npm cache clean --force
delete node_modules folder
delete package-lock.json file
sudo npm install npm#latest -g this will upgrade npm to latest version
npm audit fix --force
npm upgrade --force
npm install
After these I could finally compile SCSS files successfully with npm run dist.
Check for port availability as well if you encounter below message :
Error: listen EACCES 127.0.0.1:8080
at Object._errnoException (util.js:999:13)
at _exceptionWithHostPort (util.js:1020:20)
at Server.setupListenHandle [as _listen2] (net.js:1362:19)
at listenInCluster (net.js:1420:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1535:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:102:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
A possibly unexpected cause: you use Create React App with some warnings left unfixed, and the project fails on CI (e.g. GitLab CI/CD):
Treating warnings as errors because process.env.CI = true.
[ ... some warnings here ...]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
Solution: fix yo' warnings!
Alternative: use CI=false npm run build
See CRA issue #3657
(Ashamed to admit that it just happened to me; did not see it until a colleague pointed it out. Thanks Pascal!)
I'm using ubuntu 18.04 LTS release and I faced the same problem I tried to clean cache as above suggestions but it didn't work for me. However, I found another solution.
echo 65536 | sudo tee -a /proc/sys/fs/inotify/max_user_watches
npm start
I run this command and it started to work
In my case, I actually ran into this error "code ELIFECYCLE" in a Jenkins job. I tried to clean npm cache but it didn't work and also checked the memory of the Jenkins build server which looks okay. Then, I found the compiling of the react project actually failed in Jenkins but not in my local or when manually running the build on the Jenkins build server, and Jenkins also mentioned "Treating warnings as errors because process.env.CI = true". It looks like the warnings in my project cause the error on Jenkins. Therefore, I changed CI to true in the Jenkins job for now. That actually fixed the build error of Jenkins before I cleared those warnings.
Try to reinstall the cli package globally. In my case, I was trying to test a Vue.js tutorial when I get the same error message. The other thing I did was run the vue command again but this time using webpack-simple and that is why I am not sure wich one solved the problem but now it is working.
The port is probably being used by another application, try listing and see if it's your application:
lsof -i:8080
You can kill the process of this port:
lsof -ti:8080 | xargs kill
I've been bothered by this issue for a long time. For me, the version of node was the problem.
My npm and node were 6.1.0 and 8.11.3, respectively. However, I didn't realize that I had updated my node accidentally to 12.*.*.
It then began to install GCX stuff whenever npm i, which was unnecessary before.
I downgraded my node to 8 and it worked!
Its weird but it works for me
Go to
control panel -->System and Security--> System --> Advanced System
Security--> Environment Variables
In Environment Variable popup you will edit the user variable PATH and add "C:\Windows\System32" value as semicolon separated to the existing value.
Not but not least restart the Machine.
I did follow steps, it works:
1.
npm cache clean --force
remove theĀ package-lock.jsonĀ file
restart my WebStorm
Usually killall node command fixes mine.
Resolved like this:
# chown -R <user>: node_modules
Make sure to use the latest npm version while installing packages using npm.
While installing JavaScript, mention the latest version of NodeJS. For example, while installing JavaScript using devtools, use the below code:
devtools i --javascript nodejs:10.15.1
This will download and install the mentioned NodeJS version. This worked for me.
I was issuing the npm start command with the folder of the project opened at Sublime Text. Closing ST and restarting the server did the work for me.
Related
docker build problem with npm install and it's only inside docker I've tested. it's working on my os perfectly
Error
Step 6/8 : RUN npm cache clear --force && npm install --legacy-peer-deps
---> Running in 361c2a07ac22
npm WARN using --force Recommended protections disabled.
npm notice
npm notice New minor version of npm available! 8.4.1 -> 8.5.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.5.0>
npm notice Run `npm install -g npm#8.5.0` to update!
npm notice
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/styled-jsx: Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-02-17T07_12_06_500Z-debug-0.log
The command '/bin/sh -c npm cache clear --force && npm install --legacy-peer-deps' returned a non-zero code: 1
docker file
FROM node:alpine
WORKDIR /app
ENV PORT 3000
COPY ./package.json /app/
COPY ./.npmrc ~
RUN npm cache clear --force && npm install --legacy-peer-deps
COPY . /app/
CMD ["npm", "start"]
as u can see I have added .npmrc file because I have read it somewhere but it didn't work or add npm cache clear --force so what should I do?
What version of Node your app is using? And what version of node you have installed on your OS?
You can check it using:
node -v
This image you used node:alpine is the newest version of the node, currently it's 17. So maybe you should use older one (the one you actualy have in your app).
You can find correct image on Docker Hub
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.
I am using reactjs and am unable to install any packages using npm install. The error message I'm getting is :
npm ERR! Cannot read property 'resolve' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! /home/stash/.npm/_logs/2019-03-11T10_07_30_264Z-debug.log
When I do npm install -verbose:
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'install',
npm verb cli '-verbose' ]
npm info using npm#6.7.0
npm info using node#v11.10.1
npm verb npm-session 869376d36eca27b5
npm info lifecycle proj-lite#1.0.0-alpha.6~preinstall: proj-lite#1.0.0-alpha.6
npm timing stage:loadCurrentTree Completed in 22ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 1231ms
npm timing stage:rollbackFailedOptional Completed in 1ms
npm timing stage:runTopLevelLifecycles Completed in 2661ms
npm verb stack TypeError: Cannot read property 'resolve' of undefined
npm verb stack at regFetch (/usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js:76:23)
npm verb stack at fetchPackument (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/packument.js:42:10)
npm verb stack at packument (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/packument.js:20:10)
npm verb stack at getManifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/manifest.js:22:10)
npm verb stack at manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/manifest.js:13:10)
npm verb stack at Object.manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/index.js:17:12)
npm verb stack at Object.Fetcher#manifest [as manifest] (/usr/local/lib/node_modules/npm/node_modules/genfun/lib/genfun.js:15:38)
npm verb stack at manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetch.js:23:18)
npm verb stack at pinflight (/usr/local/lib/node_modules/npm/node_modules/pacote/manifest.js:24:12)
npm verb stack at /usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:29:24
npm verb stack at Promise._execute (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/debuggability.js:313:9)
npm verb stack at Promise._resolveFromExecutor (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:483:18)
npm verb stack at new Promise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:79:10)
npm verb stack at _inflight (/usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:28:25)
npm verb stack at /usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:22:14
npm verb stack at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
npm verb cwd /var/www/html/lite-proj/lite-proj
npm verb Linux 4.4.0-142-generic
npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-verbose"
npm verb node v11.10.1
npm verb npm v6.7.0
npm ERR! Cannot read property 'resolve' of undefined
npm verb exit [ 1, true ]
npm timing npm Completed in 3862ms
npm ERR! A complete log of this run can be found in:
npm ERR! /home/stash/.npm/_logs/2019-03-11T10_12_15_921Z-debug.log
I am not even able to uninstall npm and reinstall it as I am getting the same error when I try to uninstall. What is the issue here and how do I fix it?
I got into this situation with an old version of the n node version switcher (~v2), having switched onto Node v12. I was able to fix it by switching to a much older version of Node it had installed using n, v8 worked for me, and then upgrade the version switcher with sudo npm install -g n.
From there I could switch to any version of node and use npm again.
The reason for the error was probably conflicting global packages and node versions. I uninstalled node and npm and then reinstalled them.
To remove nodejs and associated packages (like npm):
sudo apt-get purge --auto-remove nodejs
Nodejs and npm will leave files in the system which may cause issues during reinstallation. I had to remove them as well.
Although it is a bad practice to remove packages manually (it may cause problems with the package manager), it helped my case. This answer shows how to remove nodejs and related files manually.
To reinstall them:
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
So I have recently faced a very similar problem when I was trying to run a react project in my Windows 10 x64 PC. Although I installed Node.js v12.13.0 (+ npm v6.12.0) x64; I couldn't execute npm install command, as it would give me this same error (Cannot read property 'resolve' of undefined).
Then according to this comment, I uninstalled the x64 version of Node.js and then installed the x86 version. After this, I could execute the npm install command successfully.
Anyone having this issue and have scrolled this far, if you are installing node manually and you have nvm installed then this might be the issue, don't do it manually, and don't uninstall nvm to fix the issue, just let nvm install the version for you rather than doing it manually, if you don't have nvm installed and you are lost trying upgrading/downgrading node/npm versions, then install nvm and let it handle all these things for you.
Use nvm install x.x.x, then nvm use x.x.x, and everything worked just fine.
more about nvm
The problem may occur if you are using node version manager(nvm) try uninstalling it , i had the same issue and i uninstalled nvm and tried it .
Worked with all versions of node . (worked fine with node 10.15.3,10.16 and 12.7)
I installed Node sometime ago (approximately 1 year ago) and npm worked properly.
The node version was 10.15.3. After the install and having written a few small apps - I did not work with Node again until today. Trying to install express with npm - I got the error of: "npm ERR! Cannot read property 'resolve' of undefined" even though it had worked previously.
Noting that the Node version was old, I uninstalled and installed the latest version.
In my case, I installed into the c:\NodeJs folder (where it was installed previously).
This made no difference - I got the same error.
I then uninstalled and re-installed into the default folder of c:\Program Files\nodejs and npm works again. Hopefully this might help someone else
I encountered the same issue on Windows 10.
After uninstalling node and reinstalling a newer version, I got the error "Cannot read property 'resolve' of undefined".
I then uninstalled again, manually deleted the complete installation folder (which was not removed during uninstallation !) and reinstalled the newer node release.
After that, everything worked just fine.
The same issue occurred for me on FreeBSD after I tried to update a really outdated node installation.
After removing node and npm packages (pkg delete node8-8.16.2) I had to manually remove /usr/local/lib/node_modules directory (some npm dependencies had been left behind and that caused the problem).
Instead of version 12.18.3 install version https://nodejs.org/dist/v10.15.3/node-v10.15.3-x64.msi . It will work perfectly.
There is some issue with the new node version and npm compatibility, install version [https://nodejs.org/dist/v10.15.3/node-v10.15.3-x64.msi] It will work perfectly.
The global install of this CLI started failing and I'm not sure why.
git clone https://github.com/superflycss/cli
cd cli
npm i -g
The log file is 10K lines log, but this is what it says at the end:
7353 verbose stack Error: ENOENT: no such file or directory, rename '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/#superflycss/cli-5549c074/node_modules/#babel/code-frame' -> '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/#babel/code-frame-78217d7a'
7354 verbose cwd /home/ole/SuperflyCSS/cli
7355 verbose Linux 4.15.0-45-generic
7356 verbose argv "/home/ole/.nvm/versions/node/v11.0.0/bin/node" "/home/ole/.nvm/versions/node/v11.0.0/bin/npm" "i" "-g"
7357 verbose node v11.0.0
7358 verbose npm v6.7.0
7359 error path /home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/#superflycss/cli-5549c074/node_modules/#babel/code-frame
7360 error code ENOENT
7361 error errno -2
7362 error syscall rename
7363 error enoent ENOENT: no such file or directory, rename '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/#superflycss/cli-5549c074/node_modules/#babel/code-frame' -> '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/#babel/code-frame-78217d7a'
7364 error enoent This is related to npm not being able to find a file.
7365 verbose exit [ -2, true ]
I've tried removing all global modules per the instructions here and then reinstalling. However it still fails, even with a complete local module refresh (Nuke local node_modules).
Also tried:
sudo rm -fr /home/ole/.npm-packages/*
And then npm i -g and the result is still the same.
Update
I think it might be this bug:
https://npm.community/t/global-installs-sudo-npm-i-g-fail-on-mac-after-6-5-upgrade-works-fine-after-6-4-1-downgrade/4082/15
Maybe you could try installing the superflycss CLI globally with npm through the npmjs registry as opposed to cloning the superflycss repository and trying to build from source. For example:
npm i -g #superflycss/cli
then just use it like so:
Usage: sfc [options] [command]
Hopefully that helps!
docker run -it node bash
git clone https://github.com/superflycss/cli
cd cli
npm i -g
Works just fine!
root#c3adb3ae08aa:/cli# sfc --version
1.0.0
root#c3adb3ae08aa:/cli# sfc --help
Usage: sfc [options] [command]
SuperflyCSS Command Line Interface
[more stuff here]
Try clearing your node_modules global cache and local dir.
Fixed this by upgrading to node v11.9.0 and NPM v6.7.0.
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