Skip to content Skip to sidebar Skip to footer

How To Fix 'npm Err! Cannot Read Property 'startswith' Of Null'

I am creating my first react-native app. I am attempting to install the react-native command line interface as shown here. I keep getting an error when I type the command to initia

Solution 1:

There was no proxy set in my configs in npm. I tried npm config get proxy it was null.

Try this link

Solution 2:

Solution found

  1. Uninstall current version of node.js and npm from C:\Users{your_username}\AppData\Roaming
  2. Install an older version of node.js. You can do that here. At the time of this post I installed the LTS (Node-10.15.3 & npm-6.4.1).
  3. Remove http & https environment variables. (type in environment variables in search bar which should take your straight to system variables).
  4. Temporarily disable windows defender features.
  5. Restart system
  6. Open administrator node.js command prompt
  7. Enter npm install -g react-native-cli

My result output is now as expected:

C:\Windows\System32>npm install -g react-native-cli
C:\Users\dnort\AppData\Roaming\npm\react-native -> C:\Users\dnort\AppData\Roaming\npm\node_modules\react-native-cli\index.js
+ react-native-cli@2.0.1
added 41 packages from 15 contributors in 19.22s

This post is a continuation of my 'How to fix 'npm does not support Node.js v11.14.0 error' on Windows?' here

Note: Most solutions to similar problems have been related to proxy issues, unsupported versions of node.js/npm, environment variables

Solution 3:

this may occur cause of coding error, in my case this line caused error

<img class="cat-icon" v-bind:src="require('img/icon/' + icon)" style="width:25px;" />

try to run "npm run watch" to see detailed error

Solution 4:

I ran in to similar problem which was caused by wrong ralative path when registring components by require.context

Solution 5:

I have tried a variety of commands to delete proxy settings. I found that the best way to clear out proxy settings is to clear out related entry in .npmrc. In my case, I simply empty the whole file and restart cmd. And it works.

Post a Comment for "How To Fix 'npm Err! Cannot Read Property 'startswith' Of Null'"