fex-team / fis

Front-end Integrated Solution - 前端集成解决方案, 最新版请进入 FIS3 https://github.com/fex-team/fis3
http://fis.baidu.com
MIT License
2.96k stars 654 forks source link

NPM 使用问题汇总 #565

Open oxUnd opened 9 years ago

oxUnd commented 9 years ago

现在 NPM 可谓是 node 的最佳包管理平台,很自然的 FIS 也放在上面。但是大家对 NPM 不甚了解,碰到一些稀奇古怪的安装问题觉着很摸不着头脑,然后把怒气直指 FIS。为了大家不动肝火,以及方便大家查阅,打算对常 NPM 常见问题在此汇总一下。

如何查看所有 NPM 的设置

npm config ls -l

全局安装了无法找到命令

大家都知道,FIS 是要求全局安装的,是因为避免由于 FIS 多版本不同项目目录下而导致编译时有差异,而导致不必要的麻烦。

有些同学可能遇到了

npm install -g fis

命令行执行 fis找不到这个命令。这时候一般都开始抓瞎了。

解决办法:

解决办法:

设置环境变量

出现类似这样的错误

gyp ERR! stack Error: node-v0.12.7.tar.gz local checksum 
a797be06553ea8e13a6ec9c3cdd8ed1b065dd1d05d2a3a0378296e70cf16d5ab not match remote
b23d64df051c9c969b0c583f802d5d71de342e53067127a5061415be7e12f39d

解决办法

清除缓存再进行安装

npm cache clean

安装过程中说没权限,sudo 也不行

一般发生在_类Unix_系统中

NPM 平台无奈被祖国电子长城防火墙阻隔了,时不时抽风。如果遇到这种情况只有三种解决办法;

得详细说一下为啥有这种错误,其实 node 里面不是跑得是 V8 么,那么其第三方扩展机制也全盘拿了过来。这块说的第三方扩展是指 addon 插件,也就是所谓的 native 插件。请不要被这个词语吓着了,说白了就是写一个二进制插件,用 c++ 写的。

所以这类插件需要编译器(gcc,clang,vs)编译,安装这类插件的时候如果你系统没有装 VS 或者是 gcc 什么的编译器就会报错。

而且这类插件在各个版本的 node 下兼容性不好,所以报编译语法错误也是很正常的。遇到此类错误只有两种解决办法;

由于种种维护上的原因,FIS 必须要全局安装包括其插件,有些人就受不了这个,觉着是反模式,咋眼一看确实是,但长远来看安装全局同一版本才是王道,有过 node 工程实践的同学对此估计深有体会。

但不巧,上线编译的时候用的编译机不是自己的机器,而无法部署 FIS 编译环境啊。这时候怎么办呢?

首先,我们得了解一下 NPM 安装的时候的一些处理。不才,直接贴 NPM 的文档。

DIRECTORIES
       See npm help 5 npm-folders to learn about where npm puts stuff.

       In particular, npm has two modes of operation:

       - global mode:
         npm installs packages into the install prefix at prefix/lib/node_modules and bins are installed in prefix/bin.

       - local mode:
         npm installs packages into the current project directory, which defaults to  the  current  working  directory.   Packages  are
         installed to ./node_modules, and bins are installed to ./node_modules/.bin.

       Local mode is the default.  Use --global or -g on any command to operate in global mode instead.

看到 local mode 的解释了吧。当 local mode 安装的时候,会把 bin 链接到 ./node_modules/.bin 目录下。

那么当本地安装 FIS

npm install fis

执行

./node_modules/.bin/fis -v

来调用 FIS 进行操作。

假设你想进行更方便的操作,设置两个环境变量即可。

然后就没有然后了,你可以肆意蹂躏了。

boboxiao commented 9 years ago

始终还是安装不成功!

boboxiao commented 9 years ago

报错: npm ERR! Error: shasum check failed for /tmp/npm-32475-sRV7oL_x/registry.npmjs.org/node-pngcrush/-/node-pngcrush-0.2.0.tgz npm ERR! Expected: bd87b2ad24938604ae888add94ae58fa111354c8 npm ERR! Actual: 8d663ed6b7329fbd55ac60dd1b8beae4d5d1dffd npm ERR! From: https://registry.npmjs.org/node-pngcrush/-/node-pngcrush-0.2.0.tgz npm ERR! at /usr/local/lib/node_modules/npm/node_modules/sha/index.js:38:8 npm ERR! at ReadStream. (/usr/local/lib/node_modules/npm/node_modules/sha/index.js:85:7) npm ERR! at ReadStream.emit (events.js:117:20) npm ERR! at _stream_readable.js:938:16 npm ERR! at process._tickCallback (node.js:419:13) npm ERR! If you need help, you may report this entire log, npm ERR! including the npm and node versions, at: npm ERR! http://github.com/npm/npm/issues

npm ERR! System Darwin 14.4.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "fis3" npm ERR! cwd /Users/bobo npm ERR! node -v v0.10.30 npm ERR! npm -v 1.4.21 npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/bobo/npm-debug.log npm ERR! not ok code 0

lengziyu commented 9 years ago

我和楼上一样,安装不成功!

oxUnd commented 9 years ago
npm cache clean

后重试

lengziyu commented 9 years ago

还是报错- - npm ERR! Windows_NT 6.1.7601 npm ERR! argv "F:\node\node.exe" "F:\node\node_modules\npm\bin\npm-cli. js" "install" "-g" "fis3" npm ERR! node v0.12.4 npm ERR! npm v2.10.1 npm ERR! code ENOTFOUND npm ERR! errno ENOTFOUND npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org npm ERR! network This is most likely not a problem with npm itself npm ERR! network and is related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settin gs. npm ERR! network npm ERR! network If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config'

npm ERR! Please include the following file with any support request: npm ERR! C:\Users\Administrator\npm-debug.log

oxUnd commented 9 years ago

@lengziyu 你网络不通?为什么连 npm 都访问不了?

lengziyu commented 9 years ago

@xiangshouding 额,可能是我网络问题,最近总是断线。我回家试试看,谢谢~

lengziyu commented 9 years ago

@xiangshouding 网络恢复了,安装成功了,再次感谢~慢慢开始撸FIS了

AkkaXdXd commented 9 years ago

fis-command-server@0.7.6 这个依赖找不到啊 什么情况啊

AkkaXdXd commented 9 years ago

npm WARN install Couldn't install optional dependency: No compatible version fou nd: fis-command-server@0.7.6 npm WARN install Valid install targets: npm WARN install ["0.7.5","0.7.4","0.7.3","0.7.2","0.7.1","0.7.0","0.7.0-beta6", "0.7.0-beta5","0.7.0-beta4","0.7.0-beta3","0.7.0-beta2","0.7.0-beta","0.6.12","0 .6.11","0.6.10","0.6.9","0.6.8","0.6.7","0.6.6","0.6.5","0.6.4","0.6.3","0.6.2", "0.6.1","0.6.0","0.5.9","0.5.8","0.5.7","0.5.6","0.5.5","0.5.4","0.5.3","0.5.2", "0.5.1","0.5.0","0.4.9","0.4.8","0.4.7","0.4.6","0.4.5","0.4.4","0.4.3","0.4.2", "0.4.1","0.4.0","0.3.4","0.3.3","0.3.2","0.3.1","0.3.0","0.2.8","0.2.7","0.2.6", "0.2.5","0.2.4","0.2.3","0.2.2","0.2.1","0.2.0","0.1.9","0.1.8","0.1.7","0.1.6", "0.1.5","0.1.3","0.1.2","0.1.1","0.1.0","0.0.8","0.0.7","0.0.6","0.0.4","0.0.3", "0.0.2","0.0.1"]

zhangtao07 commented 9 years ago

0.7.6 今天几小时前刚发布,可能是你的npm源还没更新,请稍后重试或者使用官方源试试

AkkaXdXd commented 9 years ago

fis3 如果css 不是相对路径的 有没有办法 修改 rel="stylesheet" type="text/css" href="<%=path%>/css/base.css"> 中的base.css 为 base_c9fff2a.css

oliverxyy commented 9 years ago

我安装好了,但是过程中出现了这个warning:npm WARN optional dep failed, continuing fsevents@0.3.8,这是神马问题撒?

AkkaXdXd commented 9 years ago

@oliverxyy npm cache clean 试试

MurphyZL commented 9 years ago

安装不成功: fix@1.9.29 uninstall C:\User\zhangling\AppData\Roaming\npm\node_modules\fis node -e "var cp = require('child_process'); cp.exec('bin/fis server stop');"

MurphyZL commented 9 years ago

安装fis3运行安装程序之后:

images@2.1.5 install C:\Users\zhangling\AppData\Roaming\npm\node_modules\fis3\node_modules\fis-spriter-csssprites\node_modules\images echo "Hello, Word."

liuhanyu200 commented 9 years ago

同上 输出 hello world 同上 源有问题 同上 输出warning:npm WARN optional dep failed, continuing fsevents@0.3.8

liuhanyu200 commented 9 years ago

现在 还在加载 估计要失败

ordheart commented 9 years ago

fis3 有米有国内资源地址,装不上哎,跪求

2413052180 commented 9 years ago

装上了,但运行fis3 -v的时候说找不到,环境变量加弄了,怎么回事啊

shenfusheng commented 9 years ago

安装完fis3,运行fis3 -v 时就会报错如下: sh.exe": /c/Users/fusheng/AppData/Roaming/npm/fis3: No such file or directory

oxUnd commented 9 years ago

@shenfusheng 请在 CMD 中执行,而不是 git-bash 亦或是 cygwin console

shenfusheng commented 9 years ago

@xiangshouding 重新再git-bash执行几次就ok了,有个疑问就是为什么一定要在CMD中执行呢?

oxUnd commented 9 years ago

@shenfusheng 因为,windows 上默认有 CMD

shenfusheng commented 9 years ago

@xiangshouding 好吧,谢谢,辛苦啦!

yunhailu commented 9 years ago

npm ERR! tar.unpack untar error /Users/MLS/.npm/fis/1.9.33/package.tgz npm ERR! Darwin 14.3.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "fis" npm ERR! node v0.12.7 npm ERR! npm v2.11.3 npm ERR! path /usr/local/lib/node_modules/fis npm ERR! code EACCES npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/fis' npm ERR! at Error (native) npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/fis'] npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! path: '/usr/local/lib/node_modules/fis', npm ERR! fstream_type: 'Directory', npm ERR! fstream_path: '/usr/local/lib/node_modules/fis', npm ERR! fstream_class: 'DirWriter', npm ERR! fstream_stack: npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25', npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53', npm ERR! 'FSReqWrap.oncomplete (fs.js:95:15)' ] } npm ERR! npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request: npm ERR! /Users/MLS/npm-debug.log

yunhailu commented 9 years ago

我用管理员,也不行,哎,愁死了。。。。

oxUnd commented 9 years ago

你可以给适当的权限以达到随心安装,比如

sudo chmod -R 777 /usr/local/

当然,你可能觉着给 777 权限太大了,你可以根据你可控制范围给权限。

liupeng110112 commented 9 years ago

basedir=dirname "$0" ^ SyntaxError: Unexpected token ILLEGAL at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Liftoff. (C:\Users\Administrator\AppD les\fis3\bin\fis.js:26:11) at Liftoff. (C:\Users\Administrator\AppD les\fis3\node_modules\liftoff\index.js:185:12) at Liftoff. (C:\Users\Administrator\AppD les\fis3\node_modules\liftoff\index.js:153:7) at process._tickCallback (node.js:415:13)

安装fis3之后报这个错(之前装过fis) 有人遇到过吗

oxUnd commented 9 years ago

重启你的 cmd 或者什么,再试呢?

liupeng110112 commented 9 years ago

以及重启过了 ,之前装的fis都删掉 以及fis3都删过 查了下没找到原因在哪

liupeng110112 commented 9 years ago

@xiangshouding 查了下是说在cmd运行shell脚本报错,我就直接把你npm里的fis这个脚本删掉了 只留了fis.cmd 在运行就没问题了, 但是有个疑问是之前装的fis也有shell脚本 装了fis3之后就报错了

Vengean commented 9 years ago

gyp WARN install got an error, rolling back install gyp ERR! configure error gyp ERR! stack Error: read ECONNRESET gyp ERR! stack at exports._errnoException (util.js:746:11) gyp ERR! stack at TCP.onread (net.js:559:26) gyp ERR! System Darwin 14.5.0 gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /usr/local/lib/node_modules/fis3/node_modules/fis3-command-release/node_modules/chokidar/node_modules/fsevents gyp ERR! node -v v0.12.7 gyp ERR! node-gyp -v v2.0.1 gyp ERR! not ok

node-pngquant-native@0.2.2 install /usr/local/lib/node_modules/fis3/node_modules/fis-optimizer-png-compressor/node_modules/node-pngquant-native echo "Hello, World"

Hello, World npm WARN optional dep failed, continuing fsevents@0.3.8

fsevents@0.3.8 install /usr/local/lib/node_modules/fis3/node_modules/fis-command-server/node_modules/chokidar/node_modules/fsevents node-gyp rebuild

---------------------------华丽的分割线------------------------- 这是什么问题Mac OS Yosemite,fis3 -v命令显示安装成功了,不影响使用吗?

narycc commented 9 years ago

我在使用mac 进行fis3 安装的时候报错:xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance。 原来是我的Mac 没有安装xcode, 到app store中去找到xcode 然后安装之后再执行npm install fis3 -gf 就可以安装成功啦。 只是,xcode的下载安装好像时间比较久,具体多久不知道,因为我放在那里就睡觉了。

alecm20 commented 9 years ago

path已经设置了,结果还是找不到fis命令。之后再试试吧

oxUnd commented 9 years ago

@mengch 设置完后重启 cmd

oxUnd commented 9 years ago

@narycc 执行 xcode-select install

lostexile commented 9 years ago

求助来了,mac安装fis-plus的时候,总是卡在node-gyp rebuild就不动了,什么情况啊。。。

liupeng110112 commented 9 years ago

@lostexile sudo 安装试试

lostexile commented 9 years ago

@liupeng110112 我就是sudo安装的。。。。

liupeng110112 commented 9 years ago

@lostexile node重新安装试试

lostexile commented 9 years ago

node也重新装过了。。。。。

oxUnd commented 9 years ago

@lostexile 截图看看

lostexile commented 9 years ago

@xiangshouding 貌似装好了,是因为我没装GCC吗?

lostexile commented 9 years ago

@xiangshouding 谢谢哈

jiangxia commented 9 years ago

安装FIS3时报错

fsevents@0.3.8 install /usr/local/lib/node_modules/fis3/node_modules/fis3-command-release/node_modules/chokidar/node_modules/fsevents node-gyp rebuild

gyp WARN install got an error, rolling back install gyp ERR! configure error gyp ERR! stack Error: node-v0.12.7.tar.gz local checksum a797be06553ea8e13a6ec9c3cdd8ed1b065dd1d05d2a3a0378296e70cf16d5ab not match remote b23d64df051c9c969b0c583f802d5d71de342e53067127a5061415be7e12f39d gyp ERR! stack at deref (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:307:20) gyp ERR! stack at IncomingMessage. (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:348:13) gyp ERR! stack at IncomingMessage.emit (events.js:129:20) gyp ERR! stack at _stream_readable.js:908:16 gyp ERR! stack at process._tickCallback (node.js:355:11) gyp ERR! System Darwin 14.4.0 gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /usr/local/lib/node_modules/fis3/node_modules/fis3-command-release/node_modules/chokidar/node_modules/fsevents gyp ERR! node -v v0.12.7 gyp ERR! node-gyp -v v2.0.1 gyp ERR! not ok npm WARN optional dep failed, continuing fsevents@0.3.8 npm ERR! registry error parsing json

麻烦大神帮忙看看感谢

rubickecho commented 9 years ago

pm ERR! tar.unpack untar error /Users/tangliangcheng/.npm/fis/1.9.37/package.tgz npm ERR! Darwin 15.0.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "fis" "--disturl=http://registry.npm.taobao.org/mirrors/node" "--registry=http://registry.npm.taobao.org" npm ERR! node v4.2.1 npm ERR! npm v2.14.7 npm ERR! path /usr/local/lib/node_modules/fis npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall mkdir

npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/fis' npm ERR! at Error (native) npm ERR! { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/fis'] npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'mkdir', npm ERR! path: '/usr/local/lib/node_modules/fis', npm ERR! fstream_type: 'Directory', npm ERR! fstream_path: '/usr/local/lib/node_modules/fis', npm ERR! fstream_class: 'DirWriter', npm ERR! fstream_stack: npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25', npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53', npm ERR! 'FSReqWrap.oncomplete (fs.js:82:15)' ] } npm ERR! npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request: npm ERR! /Users/tangliangcheng/npm-debug.log 拜托哪位大神帮我看下,这个问题要怎么弄呢

real888888 commented 8 years ago

@liupeng110112 windows下的话设置NODE_PATH=C:\Users\Administrator\AppData\Roaming\npm\node_modules

wonderbeyond commented 8 years ago

我即使换了源安装fis3也是一直挂住:

image

就在这个状态死死的挂住了, 真心不明白哪儿的问题, 期待提示.

miemiewang commented 8 years ago

npm ERR! Darwin 15.0.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "fis-bytedance" npm ERR! node v5.6.0 npm ERR! npm v3.6.0 npm ERR! path /usr/local/lib/node_modules npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules' npm ERR! at Error (native) npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/local/lib/node_modules' } npm ERR! npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request: npm ERR! /Users/wangyang/npm-debug.log 安装的时候一直显示这样,请问是什么问题呢