我在用 MEAN.io 构建项目时遇到问题。我运行了 MEAN.io 给出的所有步骤,但收到以下错误:
npm ERR! Cannot read property '0' of undefined
步骤:
- 我用 c9 创建了一个全新的 ubuntu 实例。
- 将 npm 升级到 5.3.0
- 将带有 nvm 的节点升级到 8.2.1
- 去了 mean.io,并按照那里的指示进行操作
sudo npm install -g mean-cli
mean init testapp
- 收到以下错误
错误:
Cloning into 'testapp'...
/home/ubuntu/.npm/_locks/npm-eb15ca27eba77bee.lock
/home/ubuntu/.npm/anonymous-cli-metrics.json
There are 3 files in your ~/.npm owned by root
Please change the permissions by running - chown -R `whoami` ~/.npm
/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/mean-cli/lib/install.js:52
if (err) throw err;
^
ROOT PERMISSIONS IN NPM
- 运行以下命令:
sudo chown -R
哇哇~/.npm
- 删除了表示已创建初始化的测试应用文件夹
- 重新执行命令:
mean init testapp
- 项目似乎已成功创建
- 我收到以下消息:
消息:
Install node package dependencies:
$ cd testapp && npm install
Bower install should be triggered for client side dependencies.
If it did not run invoke it manually...
$ cd testapp && bower install
Run the app by running:
$ cd testapp and then run..
$ gulp
- ran
cd testapp && npm install
- 获得以下输出
输出:
> node-sass@4.5.3 install /home/ubuntu/workspace/testapp/node_modules/node-sass
> node scripts/install.js
Cached binary found at /home/ubuntu/.npm/node-sass/4.5.3/linux-x64-57_binding.node
> node-sass@4.5.3 postinstall /home/ubuntu/workspace/testapp/node_modules/node-sass
> node scripts/build.js
Binary found at /home/ubuntu/workspace/testapp/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine
> angular-starter@6.0.0 postinstall /home/ubuntu/workspace/testapp
> npm run webdriver:update
> angular-starter@6.0.0 webdriver:update /home/ubuntu/workspace/testapp
> webdriver-manager update
[19:17:48] I/file_manager - creating folder /home/ubuntu/workspace/testapp/node_modules/protractor/node_modules/webdriver-manager/selenium
[19:17:49] I/update - chromedriver: unzipping chromedriver_2.31.zip
[19:17:49] I/update - chromedriver: setting permissions to 0755 for /home/ubuntu/workspace/testapp/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.31
[19:17:50] I/update - geckodriver: unzipping geckodriver-v0.18.0.tar.gz
[19:17:50] I/update - geckodriver: setting permissions to 0755 for /home/ubuntu/workspace/testapp/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.18.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
- 尝试运行 gop 但出现错误
错误:
[17:50:10] Local gulp not found in ~/workspace/testapp
[17:50:11] Try running: npm install gulp
- 尝试
- 运行 npm install gulp(也尝试了 sudo(,但出现以下错误
错误:
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN @angular/compiler-cli@4.0.3 requires a peer of @angular/compiler@4.0.3 but none was installed.
npm WARN @angular/compiler-cli@4.0.3 requires a peer of @angular/core@4.0.3 but none was installed.
npm WARN angular2-universal@2.1.0-rc.1 requires a peer of zone.js@~0.6.21 but none was installed.
npm WARN apollo-server@0.3.3 requires a peer of graphql@^0.6.1 || ^0.7.0 but none was installed.
npm ERR! Cannot read property '0' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2017-07-26T17_52_19_821Z-debug.log
这是日志文件的一些输出
2238 verbose unlock done using /home/ubuntu/.npm/_locks/staging-719b6a82c67d40a4.lock for /home/ubuntu/workspace/testapp/node_modules/.staging
2239 warn @angular/compiler-cli@4.0.3 requires a peer of @angular/compiler@4.0.3 but none was installed.
2240 warn @angular/compiler-cli@4.0.3 requires a peer of @angular/core@4.0.3 but none was installed.
2241 warn angular2-universal@2.1.0-rc.1 requires a peer of zone.js@~0.6.21 but none was installed.
2242 warn apollo-server@0.3.3 requires a peer of graphql@^0.6.1 || ^0.7.0 but none was installed.
2243 verbose stack TypeError: Cannot read property '0' of undefined
2243 verbose stack at rmStuff (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/lib/unbuild.js:61:24)
2243 verbose stack at tryCatcher (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
2243 verbose stack at ret (eval at makeNodePromisifiedEval (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
2243 verbose stack at lifecycle.then.then (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/lib/install/action/unbuild.js:12:12)
2243 verbose stack at tryCatcher (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
2243 verbose stack at Promise._settlePromiseFromHandler (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
2243 verbose stack at Promise._settlePromise (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
2243 verbose stack at Promise._settlePromise0 (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
2243 verbose stack at Promise._settlePromises (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
2243 verbose stack at Async._drainQueue (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
2243 verbose stack at Async._drainQueues (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
2243 verbose stack at Immediate.Async.drainQueues (/home/ubuntu/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
2243 verbose stack at runCallback (timers.js:781:20)
2243 verbose stack at tryOnImmediate (timers.js:743:5)
2243 verbose stack at processImmediate [as _immediateCallback] (timers.js:714:5)
2244 verbose cwd /home/ubuntu/workspace/testapp
2245 verbose Linux 4.9.17-c9
2246 verbose argv "/home/ubuntu/.nvm/versions/node/v8.2.1/bin/node" "/home/ubuntu/.nvm/versions/node/v8.2.1/bin/npm" "install" "gulp"
2247 verbose node v8.2.1
2248 verbose npm v5.3.0
2249 error Cannot read property '0' of undefined
2250 verbose exit [ 1, true ]
知道出了什么问题吗?
这是npm@5.3.0
的问题。尝试通过以下命令降级 npm,然后再次安装 npm。
npm install -g npm@5.2.0