gpt4 book ai didi

ubuntu - gulp -v 安装后报错

转载 作者:行者123 更新时间:2023-12-04 18:32:28 25 4
gpt4 key购买 nike

我正在尝试在我的 Vagrant 机器(Ubuntu 机器)上使用 gulp,因此像这样安装它:

sudo apt-get install nodejs npm
sudo npm install -g gulp

但是在尝试 gulp -v 我得到了这个:
vagrant@laravel:/var/www$ gulp -v

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'optimist'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/usr/local/lib/node_modules/gulp/bin/gulp:4:10)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:41)

所以我另外跑了 sudo npm install -g optimist .上述错误已解决,但现在我被困在这个问题上:
vagrant@laravel:/var/www$ gulp -v

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: undefined is not a function
at /usr/local/lib/node_modules/gulp/bin/gulp:26:12
at Array.filter (native)
at getGulpFile (/usr/local/lib/node_modules/gulp/bin/gulp:25:6)
at Object.<anonymous> (/usr/local/lib/node_modules/gulp/bin/gulp:8:18)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:41)

有任何想法吗?谢谢!

PS。这些是运行的版本:
vagrant@laravel:/var/www$ node -v
v0.6.12
vagrant@laravel:/var/www$ npm -v
1.1.4

最佳答案

您的 NodeJS版本太旧了。这很可能是问题所在,Gulp似乎只在 >= 0.9 上运行.

这是由于 apt-get包已经过时了,你可以使用这个 Vagrant 脚本获得最新版本:

config.vm.provision :shell, inline: "sudo add-apt-repository ppa:chris-lea/node.js"
config.vm.provision :shell, inline: "sudo apt-get update"
config.vm.provision :shell, inline: "sudo apt-get install -y nodejs --no-install-recommends"

A example of a working Vagrant file with the newest node can be found here.

还有其他获取最新版本的方法 Node版本,但这个应该工作。

关于ubuntu - gulp -v 安装后报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23308077/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com