0

i'm using node v16.7.0 and npm v7.20.3. I bought new laptop(w10) and installed node but since that(almost a week), i couldn't start any node related project because i can not install any npm package. Whenever i try to 'npm install'

npm install <package>

I get the error:

npm ERR! Cannot read property 'version' of null

I dig into all around web to find a solution for this but i couldn't get one. Can someone help me with this issue this is my first question in Stackoverflow.Also if i use dual boot with Ubuntu or WSL2(Web Subsystem for Linux) will i get less errors with development tools even though i'm into web development nothing to do with kernel. Thanks...

Edit: I had spaces and non English character in my username folder in Windows so i tried changing my username and username folder and it solved my problem.(Note that changing username does not reflect to username folder you have to set extra configuration for that).

8
  • 1
    Installed node how? And on which OS? Because I'd recommend uninstalling and either using nvm on linux/macos, and nvm-win for windows so that you can easily manage your node and npm versions. Commented Aug 21, 2021 at 18:39
  • Try this command in your terminal for your first warning, 1.$ npm cache clean --force 2.delete node_modules by $ rm -rf node_modules 3.$ npm install And then start it again with $ npm start Commented Aug 21, 2021 at 18:42
  • Can you try removing the old lock files from project and then doing a fresh install, like so: rm -rf package-lock.json node_modules && npm install? Commented Aug 21, 2021 at 18:42
  • @Mike'Pomax'Kamermans it's windows 10 never heard of nvm-win if this is going to solve my problem i'll definitely install node with that. Commented Aug 21, 2021 at 19:15
  • 1
    Thank you all. I installed nvm-win and i got another problem with it. I looked it up and found out that my user folder name had included non English character and a space in it and that might cause issues. Eventually i renamed my username folder with appropriate name and that solved my problem. Commented Aug 22, 2021 at 12:35

1 Answer 1

1

The error message means that npm is trying to read the version property of the folder's package.json file but doesn't find the file.

Check that you have a package.json file inside your folder, and see what's the value of the version property.

If you need to create a package.json file out of the box, run npm init and follow the instructions. For more information, view the npm documentation about npm init.

Also, make sure that you've installed Node correctly. It's recommended to use a Node version manager to manage your Node installations.

Also if i use dual boot with Ubuntu or WSL2(Web Subsystem for Linux) will i get less errors with development tools even though i'm into web development nothing to do with kernel

Yes, and dual-booting with Ubuntu would be best. Virtual machines can be slow and require additional configurations to improve performance, and a lot of issues are reported on WSL.

Most development tools work natively with Linux and therefore run better on Linux. Ultimately, it depends on what language you're developing with and what environment you're developing for.

In general, Linux will make your development experience much less of a hassle. Information, tutorials, and troubleshooting about those tools is also more easily available for Linux.

One of the best things about switching from Windows to Linux is for package management and the command-line interface. Linux makes it easy and straightforward to run commands, whereas Windows can require additional configurations, other workarounds, and intermediary steps.

Sign up to request clarification or add additional context in comments.

1 Comment

My username folder was including non English character and a space in it. So i changed my username folder and installed node version manager as you mentioned and that solved my problem. Thanks for the help and information about Linux. I will definitely dual-boot with Ubuntu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.