简体   繁体   English

NPM将模块安装到应用程序根目录

[英]NPM installing modules to application root

I messed something up and I've done my best to fix it, but no luck. 我搞砸了,已经尽力解决了,但是没有运气。

Whenever I run 'npm install' on a new node project, it installs all of my dependencies to the root of the application instead of in /node_modules/ like you'd expect in a default application. 每当我在新的节点项目上运行“ npm install”时,它将所有我的依赖项安装到应用程序的根目录,而不是像在默认应用程序中期望的那样安装在/ node_modules /中。

For example- 例如-

My package.json 我的package.json

{
  "name": "hello-world",
  "description": "hello world test app",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "express": "3.x"
  }
}

When I use 'npm install' I end up with this: 当我使用“ npm install”时,结果如下:

I've tried setting my PATH like in this solution: How to use package installed locally in node_modules? 我曾尝试像以下解决方案一样设置PATH: 如何使用在node_modules中本地安装的软件包?

but that didn't seem to do much. 但这似乎并没有太大作用。 Help? 救命?

observe that you have the cache variable set in that directory 观察您在该目录中设置了缓存变量

strict-ssl = false
userconfig = /private/tmp/timothy/timothy_local_job_1367532952281_60137/.npmcfg
cache = /Users/tomhorton/Documents/Repository/helpmestackoverflow
root = ./node_modules

That timothy stuff is from a module that I installed shortly before everything went haywire- 那些令人讨厌的东西来自我在一切陷入困境之前不久安装的一个模块-

I removed that stuff and the defaults took over. 我删除了这些东西,默认值接管了。 Everything works great! 一切正常!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM