Reputation: 3
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).
Upvotes: 0
Views: 5724
Reputation: 1077
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.
Upvotes: 1