Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NODE_PATH matches the npm root - Unable to find the npm root, something went wrong. #59

Open
nandaccio opened this issue Dec 21, 2021 · 1 comment

Comments

@nandaccio
Copy link

nandaccio commented Dec 21, 2021

I am unable to run yo, so I ran "yo doctor" and I am getting the error message below.

Yeoman Doctor
Running sanity checks on your system

√ No .bowerrc file in home directory
√ Global configuration file is valid
× NODE_PATH matches the npm root

Unable to find the npm root, something went wrong.
Try to execute npm -g root --silent on your command-line

√ No .yo-rc.json file in home directory
√ Node.js version
√ npm version
√ yo version

Found potential issues on your machine :(

NOTES:

  • NODE_PATH is set to c:\Program Files\nodejs\node_modules\
  • npm -g root --silent returns: C:\Program Files\nodejs\node_modules
  • Node.js version: 17.3.0
  • I ran "yo doctor" both as a regular user and as an administrator, same issue
  • yo --version: 4.3.0

image

@appsparkler
Copy link

appsparkler commented May 27, 2022

Placing the generator index.js file inside generators/app instead of the root of the generator project worked for me.

// ./generator/app/index.js
var Generator = require('yeoman-generator');

// Try this sample generator
module.exports = class extends Generator {
    constructor(args, opts) {
        // Calling the super constructor is important so our generator is correctly set up
        super(args, opts);
    }
    method1() {
        this.fs.write(this.destinationPath('index.js'), 'const foo = 1;');
    }
};

Now, you might still have an error with yo doctor; however, you'll have a working generator.

A better approach would be is to use Yeoman's generator-generator as a starter kit for your generator and then build on top of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants