麻烦用MEAN.io构建平均项目

时间:2017-07-26 19:24:36

标签: angularjs node.js express mean-stack mean.io

我在使用MEAN.io构建项目时遇到问题。我完成了MEAN.io给出的所有步骤,但收到以下错误:

npm ERR! Cannot read property '0' of undefined

步骤:

  1. 我用c9创建了一个全新的ubuntu实例。
  2. 将npm升级至5.3.0
  3. 使用nvm升级到8.2.1
  4. 的节点
  5. 去意味着。并遵循指示
    • sudo npm install -g mean-cli
    • mean init testapp
    • 收到以下错误
  6. 错误:

    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
    
    1. 运行以下命令:sudo chown -R whoami ~/.npm
    2. 删除了表示init created
    3. 的testapp文件夹
    4. 删除命令:mean init testapp
    5. 似乎已成功创建项目
    6. 我收到以下消息:
    7. 消息:

        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
      
      1. cd testapp && npm install
      2. 得到以下输出
      3. 输出:

        > 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"})
        
        1. 尝试运行gulp但出现错误
        2. 错误:

          [17:50:10] Local gulp not found in ~/workspace/testapp
          [17:50:11] Try running: npm install gulp
          
          1. 尝试运行npm install gulp(也尝试过sudo)但出现以下错误
          2. 错误:

            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 ]
            

            知道出了什么问题吗?

1 个答案:

答案 0 :(得分:0)

这是npm@5.3.0的问题。尝试通过以下命令和npm install再次降级npm。

npm  install -g npm@5.2.0