简体   繁体   English

ionic3 - nvm 与 npm 配置“前缀”选项不兼容:当前设置为“/usr/local”

[英]ionic3 - nvm is not compatible with the npm config “prefix” option: currently set to “/usr/local”

This is ionic3 project, after I installed nvm , can running without warning.这是 ionic3 项目,安装nvm ,可以无警告运行。 But when I restart my mac and restart VSCode that warning coming out.但是当我重新启动我的 mac 并重新启动 VSCode 时,警告就会出现。

nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local" Run npm config delete prefix or nvm use --delete-prefix v8.6.0 --silent to unset it. nvm 与 npm config "prefix" 选项不兼容:当前设置为 "/usr/local" 运行npm config delete prefixnvm use --delete-prefix v8.6.0 --silent取消设置。

nvm --version 0.33.8 nvm --version 0.33.8

ionic info离子信息

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.7
    Cordova Platforms  : android 6.3.0 ios 4.4.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    ios-deploy : 1.9.2
    Node       : v6.11.3
    npm        : 3.10.10
    OS         : macOS Sierra
    Xcode      : Xcode 9.2 Build version 9C40b

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

Add this to VSCode settings:将此添加到 VSCode 设置:

"terminal.integrated.shellArgs.osx": []

As discussed here .正如这里所讨论的。

nvm will manage node packages folder based on installing node. nvm将根据安装节点管理节点包文件夹。 To solve your problem just delete or unset the "prefix" setting:要解决您的问题,只需删除或取消设置“前缀”设置:

npm config delete prefix npm 配置删除前缀

if this not help try to remove the prefix value manually.如果这没有帮助,请尝试手动删除前缀值。 Edit the "~/.npmrc" file and remove the "prefix" variable.编辑“~/.npmrc”文件并删除“prefix”变量。

I got this same error msg in VSC's integrated terminal when running npm run start .运行npm run start时,我在 VSC 的集成终端中收到了同样的错误消息。 The error message is displayed as soon as the terminal is loaded, but it doesn't happen on my external terminal (using iTerm2).加载终端后立即显示错误消息,但它不会发生在我的外部终端上(使用 iTerm2)。

I know this happened to me bc I globally installed npm using another version of node .我知道这发生在我身上,因为我使用另一个版本的node全局安装了npm

To resolve it, I went ahead and looked for the old npm folder and removed it.为了解决这个问题,我继续寻找旧的npm文件夹并将其删除。

Find the path by running which npm and then find old node_modules to remove by running this: ls -la /usr/local/bin | grep "np[mx]"通过运行which npm找到路径,然后通过运行以下命令找到要删除的旧 node_modules: ls -la /usr/local/bin | grep "np[mx]" ls -la /usr/local/bin | grep "np[mx]" . ls -la /usr/local/bin | grep "np[mx]" This will give you two paths, so use these two paths to remove by running the following:这将为您提供两条路径,因此通过运行以下命令使用这两条路径进行删除:

rm -R /usr/local/bin/npm /usr/local/node_modules/npm/bin/npm-cli.js
rm -R /usr/local/bin/npx /usr/local/node_modules/npm/bin/npx-cli.js

Restart VSC and open a new terminal to run npm run start , and you shouldn't encounter the issue anymore.重新启动 VSC 并打开一个新终端来运行npm run start ,您应该不会再遇到这个问题了。

Just remove .npmrc file from root directory.只需从根目录中删除.npmrc文件。 Redefine your custom configuration for node.重新定义节点的自定义配置。 This time will work!这一次会奏效的!

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

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