'problem installing truffle using "npm i truffle -g"

I am having this problem while installing truffle for my project. I have installed visual studio and also python and node-gyp but this is not going away. Also what is this deprecated warning. Please help.

npm install truffle -g

Error I am getting



Solution 1:[1]

Try the following commands: (assuming your work is in project directory)

 - cd project 
 - npm init -y 
 - npm install truffle

This will install truffle inside node_modules of the project directory. Now to run truffle commands:

npx truffle <command>

e.g.

npx truffle migrate

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Muhammad Niazullah Khan