Skip to content

Errors when searching for libs #44

@htaunay

Description

@htaunay

I am interested in customising my 'npm init' process (e.g. defining different default values or adding new settings to the generated 'package.json') and was under the impression that this could be done by adding a '~/.npm-init.js' file with contents similar as to the one described in the 'README.md' of the 'init-package-json' project.

However, I am stumbling upon what I believe are some path/configuration issues, mainly consisting of 'node_modules' not being found, despite the necessary dependencies being available in the global 'node_modules' dir.

Here is a simple example:

[myuser ~/test]$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sane defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
npm ERR! Linux 2.6.32-504.8.1.el6.centos.plus.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "init"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module 'glob'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <http://github.com/npm/npm/issues>
About to write to /home/myuser/test/package.json:

{
  "name": "",
  "version": ""
}


Is this ok? (yes) no
Aborted.

As already stated, glob is already globally available (installed with -g).
Now, if I try to explicitly set the node path, I get errors regarding other libs not available globally:

[myuser ~/test]$ NODE_PATH=/usr/lib/node_modules npm init

npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'validate-npm-package-name'

I could globally install the other necessary packages... but I feel that I may be tackling this problem the wrong way, and that manually specifying the node path plus manually installing dependencies seems like overkill. Am I missing some step/configuration that should allow the '~/.node-init.js' integration work more seamlessly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions