【发布时间】:2016-01-20 20:47:15
【问题描述】:
我相信这可能会发生,因为我使用 brew 安装 npm;我想我可能有两个不同的版本。这是错误:
npm run watch
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/Cellar/node/5.4.1_1/bin/node" "/usr/local/bin/npm" "run" "watch"
npm ERR! node v5.4.1
npm ERR! npm v3.5.3
npm ERR! path /Users/Nicolas/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/Nicolas/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/Users/Nicolas/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Nicolas/Code/wordpress/wp-content/themes/IMFA-theme/npm-debug.log
我尝试了以下方法:
- brew doctor(发出很多警告,似乎没有任何改变)
- brew unlink and re-link(似乎没有做任何事情)
不管怎样,我最近卸载并重新安装了 brew,我知道有一些未链接的小桶;我在运行 brew doctor 时看到了这个,但我不知道如何解决它。
其他 npm 命令似乎仍然有效,例如 npm install。但是,在我要编译 SCSS 的目录中,npm run watch 给了我上面的错误。任何帮助表示赞赏
【问题讨论】:
-
在你的 package.json 文件中 "scripts" 的值是什么 : { "watch" : "?" }
-
在我看来你在错误的文件夹中运行 npm,你在你的主文件夹中运行它,这通常不是项目的根目录。至少 npm 在那里找不到 package.json 文件。确保您在正确的目录中,然后重试。
-
如果我已经 cd'd 进入项目文件夹并使用 npm run watch,我仍然会收到上述错误。无论我在哪里尝试执行 npm,我似乎都能得到它