Node error Cannot read property 'resolve' of undefined - javascript
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.
Related
Error: You are running `create-react-app` 5.0.0, which is behind the latest release (5.0.1)
As the title says, I cannot run create-react-app. You are running `create-react-app` 5.0.0, which is behind the latest release (5.0.1). We no longer support global installation of Create React App. Please remove any global installs with one of the following commands: - npm uninstall -g create-react-app - yarn global remove create-react-app The latest instructions for creating a new app can be found here: https://create-react-app.dev/docs/getting-started/ Doing this does not change the error. npm uninstall -g create-react-app I entered this command to try it out and got a message that the tar was out of date. npm install -g create-react-app npm WARN deprecated tar#2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap. npm ERR! code EEXIST npm ERR! path /opt/homebrew/bin/create-react-app npm ERR! EEXIST: file already exists npm ERR! File exists: /opt/homebrew/bin/create-react-app npm ERR! Remove the existing file and try again, or run npm npm ERR! with --force to overwrite files recklessly. npm ERR! A complete log of this run can be found in: https://www.npmjs.com/package/tar I ran the command with this reference. However, the tar was not updated. I have already tried all the published solutions, but they don't work. Can someone please help me? Please. I tried clearing the cache but could not solve the problem. npx clear-npx-cache Need to install the following packages: clear-npx-cache Ok to proceed? (y) y I was able to successfully run the following command by specifying the version each time, but it is a hassle and I want to be able to run it normally. npx create-react-app#latest my-app
The "fish" shell I am currently using is node v18.0.0, so I downgraded to v16.15.0 and it works fine. fisher install jorgebucaran/nvm.fish nvm install v16 I had forgotten to lower the node version in fish because it had been working fine with zsh.
node-pre-gyp install error on npm install
I was trying to follow the react in action book. - book's project repo But on doing npm install on Ubuntu, I am getting npm ERR! errno 1 npm ERR! grpc#1.7.3 install: `node-pre-gyp install --fallback-to-build --library=static_library` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the grpc#1.7.3 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.` I have also tried to update my node and npm version and then npm install but it's still not working . Help me to fix this irritating error . Edit: I have tried to fix this using almost 10 answers from SO as well as github but none of them works and also some of the answer is for windows or mac and not for ubuntu. I have tried the answers to these questions too.
This issue just wasted my day. I went through a lot of solutions like installing node-pre-gyp, uninstall and reinstall node and npm, cleared the cache and node modules and reinstall installed the dependency. But none of the solutions worked. At last, I fixed it by downgrading the npm version from v10.xx to v9.9.0. Steps that I followed (for mac): Open terminal and type sudo npm install -g n Once step 1 done, type n 9.9.0 to downgrade the npm version Hope it helps :)
npm ERR! request to https://registry.npmjs.org/node-modules failed, reason: error:0906D06C:PEM routines:PEM_read_bio:no start line
I am getting this error while installing any JS package , I have done lots of search but no luck. So please let me know where i am making mistake. npm ERR! request to https://registry.npmjs.org/node-modules failed, reason: error:0906D06C:PEM routines:PEM_read_bio:no start line WebServer : Apache2(xampp) Node : v9.3.0 NPM : 5.5.1
I think that first you need to start prompt as an administrator, then run npm cache clean -f then try to run npm install, by this command the npm will install the packages listed in package.json. Or You can run npm config set registry http://registry.npmjs.org/ so you can run npm install -g node-modules. Read more in this answer.
I faced the same problem and finally I was able to solve the exact above error by doing the following steps:- check version of your npm with npm -v run npm -g install npm#<version> This step is important as npm is getting installed globally here. Now run the command where you want to install something globally using npm. In my Case the command was npm install -g #angular/cli#6.2.9 which worked fine after these changes If you are still facing the problem, I would recommend to follow the instructions about installing nodejs perfectly from here https://docs.npmjs.com/try-the-latest-stable-version-of-npm#upgrading-on-windows
Maximum call stack size exceeded on npm install
I'm trying to run npm install, this is output from console: npm ERR! Linux 4.8.0-27-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" npm ERR! node v6.9.1 npm ERR! npm v3.10.8 npm ERR! Maximum call stack size exceeded npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! <https://github.com/npm/npm/issues> and this is content of npm-debug.log: 113791 verbose stack RangeError: Maximum call stack size exceeded 113791 verbose stack at Object.color (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/console-control-strings/index.js:115:32) 113791 verbose stack at EventEmitter.log._format (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:252:51) 113791 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:138:24) 113791 verbose stack at emitThree (events.js:116:13) 113791 verbose stack at emit (events.js:194:7) 113791 verbose stack at .<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js:23:18) 113791 verbose stack at emitThree (events.js:116:13) 113791 verbose stack at emit (events.js:194:7) 113791 verbose stack at .<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js:23:18) 113791 verbose stack at emitThree (events.js:116:13) 113791 verbose stack at emit (events.js:194:7) 113792 verbose cwd /home/giorgi/AdMove/dev/web-advertiser-admove 113793 error Linux 4.8.0-27-generic 113794 error argv "/usr/bin/nodejs" "/usr/bin/npm" "install" 113795 error node v6.9.1 113796 error npm v3.10.8 113797 error Maximum call stack size exceeded 113798 error If you need help, you may report this error at: 113798 error <https://github.com/npm/npm/issues> 113799 verbose exit [ 1, true ] Removed node_modules several times and tried to reinstall. Can't understand what's the reason that causes this and how to fix it.
metzelder's answer helped me fix the issue. however if you run the command npm cache clean, it will give you a message As of npm#5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid So, as of npm5 you can do by adding a --force flag to the command. So the command is: npm cache clean --force
npm rebuild it has solved my problem
Try removing package-lock.json and the node_modules folder: rm package-lock.json rm -r node_modules
I had the same issue with npm install. After a lot of search, I found out that removing your .npmrc file or its content (found at %USERPROFILE%/.npmrc), will solve this issue. This worked for me.
npm uninstall npm cache clean --force I tried these two methods but they didn't work. After, I deleted the node_modules directory and ran npm install again, it still didn't work. Lastly, I deleted package-lock.json and created a new package-lock.json file using npm install
I have overcome this issue by doing following: Delete all the content of the npm dependencies. You can find the default install location according to this thread: https://stackoverflow.com/a/5926706/1850297 Before you run npm install command, I suggest to run npm cache clean --force
npm rebuild will work for sure
In my case, update to the newest version: npm install -g npm
I deleted node_modules and then reinstalled by npm install It worked for me
I have also faced the same problem and this is how i resolved it. First of all you need to make sure that your node and npm versions are up to date. if not please upgrade your node and npm packages to latest versions. nvm install 12.18.3 // update node version through node version manager npm install npm // update your npm version to latest Delete your node_modules folder and package-lock.json file. Force clean the entire NPM cache by using following comand. npm cache clean --force Re-Install all the dependencies. npm install If above step didn't resolve your problem, try to re-install your dependencies after executing following command. npm rebuild
This issue can also happen if you're trying to install a package that doesn't exist or if you're trying to install a version that doesn't exist.
npm cache clean returns below message As of npm#5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead. On the other hand, if you're debugging an issue with the installer, you can use npm install --cache /tmp/empty-cache to use a temporary cache instead of nuking the actual one. If you run npm cache verify, as specified above, then it actually runs cache verification and garbage collection which fixes the problem. Cache verified and compressed (~\AppData\Roaming\npm-cache_cacache): Content verified: 6183 (447214684 bytes) Content garbage-collected: 16 (653745 bytes) Index entries: 9633
Happened in docker (node:15-buster) for me. Remember to use WORKDIR /<folder> so that it doesn't conflict with original npm libraries installed. The folder can be anything but system folders, so that includes using /.
In case none of these answer work for you, it may be because the terminal you're using isn't the right one/ your node_modules is used by another part of your computer. In my case I kept juggling between this error (maximum call stack size exceeded) and the access error event when I did a sudo npm i. The fix was to close my IDE (which was WebStorm), run npm i in a basic terminal, and that was it.
I'm not a Windows user, so if you are, try to check Rene Knop comment. For Unix/OSX users, I've removed the root .npmrc file ~/.npmrc. Before you're going to try it, please, check if there is nothing necessary over there you can use this command to bring all content into your terminal: cat ~/.npmrc . If you have got something like: cat: /Users/$USER/.npmrc: No such file or directory to save a copy: cp ~/.npmrc ~/.npmrc_copy Now, try to remove it (Works for bash users: Unix / Ubuntu / OSX ...): rm -f ~/.npmrc This worked for me. Hope this will be helpful for others.
I also had the same problem. I had tried the previous solutions, but the solution for me was much simpler. I only had to remove the space in the directory and then run npm i again Thanks to: https://github.com/nodejs/node-gyp/issues/809#issuecomment-155019383 for pointing this out.
In my case I had a custom .npmrc file that included an auth token for authenticating with a private npm registry. The token had expired, which helpfully returned code E401: Incorrect or missing password locally, but ERR! Maximum call stack size exceeded from the CI build.
You uninstall npm package and force clean the cache and close terminal and reinstall whichever package be. $sudo npm uninstall <package - name> $sudo npm cache clean --force Then restart terminal and check Still not working upgrade both npm and node to the latest version
Today we encountered this error when running an npm prune even after running an npm cache clean --force. Versions: node 13.8.0 npm 6.13.6 Deleting the package-lock.json worked for this case as well. Thank you all!
In general, once a module has been installed, it's much more convenient to use npm ci instead of npm install. Please check out this SO answer for the advantages of the former with respect to the later in a production environment. So please just run npm ci All dependencies will be updated, and the problem will disappear. Or it will error in the case there's some grave de-synchronization between one and the other.
Most of the times, this issue occurs if you are using the system provided by the organization you work for and it's vpn restricts the use of this command. In this case, you may try to disconnect from organization vpn and then execute this command.
I tried everything to fix this issue on my Mac. I think the issue started when I had already downloaded npm from Node.js and then reinstalled it with Homebrew while following along with a Team Treehouse video. Here's what I tried: From https://docs.npmjs.com/misc/removing-npm sudo npm uninstall npm -g sudo make uninstall sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm* From How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*} Here's what worked: In the end, the only thing that worked for me was to clone down the npm-reinstall repo from GitHub that completely removed everything related to npm on my Mac. https://github.com/brock/node-reinstall I then had to reinstall node and npm from Node.js.
I tried everything to fix this issue on my windows 7 machine like Reinstalling and rebuilding npm At last, I fixed this small configuration setting issue by wasting my entire day. How I resolved this issue Removing my project specific configurations in global .npmrc at location like drive:/Windows/Users/../.npmrc
I solved it 100% I had this problem with gulp version: 3.5.6. You should clean the package-lock.js and then run npm install and It worked form
Our company dev environment uses Artifactory as the default registry for our NPM dependencies, and when running npm install it was defaulting to this, which did not work... so manually specifying the main npm registry via npm install --registry https://registry.npmjs.org fixed this issue for me...
I was facing the same error, I was trying to install jest into to one of the packages in a monorepo project. If you are using Yarn + Learna to package a monorepo project, you will have to navigate to the package.json inside the target package and then run npm install or npm install <package name>.
I don't know why, but I ran npm install with sudo and it worked. sudo npm install
I had this problem and it was due to an upgrade of my git executable. I rolled back to Git-2.21.0.rc1.windows.1-64-bit and added this to my environment path and it fixed my issue.
The one thing that finally worked for me on Mac was upgrading from node 8.12 to 10.x using NVM. I uninstalled all other versions of Node with NVM, then installed 10.x, then ran nvm alias default node, which tells NVM to always default to the latest available node version on a shell. After that, my live reloading issue went away!
Switching to yarn solved the issue for me.
Failed at the node-sass#0.9.6 install script 'node build.js'
I'm getting this error while running npm install on project. The additional information about this issue below, npm ERR! node-sass#0.9.6 install: `node build.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the node-sass#0.9.6 install script 'node build.js'. npm ERR! This is most likely a problem with the node-sass package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node build.js npm ERR! You can get their info via: npm ERR! npm owner ls node-sass npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! /home/capricornus/Projects/aware-app/npm-debug.log
Just install older version of Nodejs with nodebrew. curl -L git.io/nodebrew | perl - setup Add the following to ~/.bashrc export PATH=$HOME/.nodebrew/current/bin:$PATH Refresh console source ~/.bashrc Install older version nodebrew install-binary v0.12.7 nodebrew use v0.12.7 Then try again!
It looks like this version is no longer compatible. I get the same errors on my system. Either you need to downgrade node to the supported version, or upgrade the dependencies that require node-sass#0.9.6. Latest version of node-sass is 3.4.2.
In case someone runs into trouble with nodebrew, it's also possible to use nvm (node version manager) to downgrade your node version. Project on Github On OSX El Capitan, I needed this for the installation: curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash . ~/.nvm/nvm.sh Mind the last line, as it's slightly different from the install instruction on github. As mentioned by Yosuke Sato, v0.12.7 is compatible with node-sass#0.9.6, so you'd need nvm install v0.12.7 or nvm use v0.12.7 (if you have it installed already) This will use the older node version, but only in the current terminal window/tab.
nvm use v0.12.7 in the project directory followed by npm install solved the problem for me -- the error occurred as I was trying to set up broccoli-taco, a static site generator. Thanks for tip, I am glad I googled you up.