【发布时间】:2021-03-06 11:51:47
【问题描述】:
我在项目中使用 grunt 时遇到问题。我正在设置版本 11.0.1 的 macos 计算机。 项目文件(本地)原则上是正确的,因为我在另一台计算机上使用它并且在那里工作正常。
我已经尝试解决这个错误两天多了,问题是本地配置无法正常工作,因为我收到消息 ~ bash: grunt command not found when trying to initialize grunt with the @987654321 @ 或 grunt watch 命令
尝试全局安装 grunt-cli 时出现此错误:
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /Users/bertanicolau/.npm-packages
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/Users/bertanicolau/.npm-packages'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/bertanicolau/.npm/_logs/2020-11-23T17_06_23_295Z-debug.log
.npm-packages 文件夹在此位置不存在,而 .npm 文件夹确实存在,我不知道它为什么要寻找另一个。
我已经尝试清除 npm 缓存,我还尝试删除 package-lock.json 文件并更改 .bash-profile 上的路径,但这些似乎都不起作用。
会不会是 npm 或 node 版本的 bug?
$ npm -v && node -v
7.0.8
v15.2.1
谢谢!
【问题讨论】:
-
.npm-packages是什么? NPM 根据package.json中的信息将东西安装到node_modules,如果有的话,锁定到package-lock.json中指示的版本。如果你全局安装(没有理由再安装了,因为npx带有 node 并且已经在很多版本中这样做了),那么它们仍然会进入node_modules,就在 npm 的特殊全局数据目录中。跨度>