Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 运行时出错";npm安装“;对根目录进行编译_Node.js_Angular_Vagrant - Fatal编程技术网

Node.js 运行时出错";npm安装“;对根目录进行编译

Node.js 运行时出错";npm安装“;对根目录进行编译,node.js,angular,vagrant,Node.js,Angular,Vagrant,我正在尝试为运行angular-2客户端设置一个流浪环境 这是我的文件: Vagrant.configure("2") do |config| config.vm.box = "hashicorp/precise64" config.vm.provision :shell, path: "vagrant-provision-npm-angular-2.sh" end 这是我的流浪者-provision-npm-angular-2.sh #! /bin/bash echo

我正在尝试为运行angular-2客户端设置一个流浪环境

这是我的文件:

Vagrant.configure("2") do |config| 
    config.vm.box = "hashicorp/precise64"

    config.vm.provision :shell, path: "vagrant-provision-npm-angular-2.sh"

end
这是我的流浪者-provision-npm-angular-2.sh

#! /bin/bash

echo "prereqs install openssl"
sudo apt-get install libssl1.0.0

echo "prereqs install ntp"
sudo apt-get install ntp -y
sudo service ntp stop
sudo ntpd -gq
sudo service ntp start

echo "prereqs install curl"
sudo apt-get update && sudo apt-get install curl -y

echo "install zip"
sudo apt-get install unzip

echo "create directory"
mkdir /downloads -p
pushd /downloads

echo "install python 2.7"
sudo apt-get install python2.7 -y

echo "get pip"
curl -O https://bootstrap.pypa.io/get-pip.py 

echo "execute get-pip.py"
sudo python get-pip.py
popd

echo "install aws cli"
sudo pip install awscli

echo "install nodejs"
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

echo "update npm"
npm install npm@latest -g

echo "intall angular cli (beta- require Node 4 or higher, together with NPM 3 or higher)"
npm install -g angular-cli
一切似乎都安装正常,但当我使用ssh对根目录运行“npm install”进行编译时,出现以下错误:

vagrant@precise64:/vagrant$ sudo npm install

> ng2-uploader@1.5.7 postinstall /vagrant/node_modules/ng2-uploader
> ngc -p tsconfig.json

Error: Error Cannot find type definition file for 'node'.
    at Object.check (/vagrant/node_modules/@angular/compiler-cli/node_modules/@angular/tsc-wrapped/src/tsc.js:31:15)
    at Object.main (/vagrant/node_modules/@angular/compiler-cli/node_modules/@angular/tsc-wrapped/src/main.js:26:15)
    at Object.<anonymous> (/vagrant/node_modules/@angular/compiler-cli/src/main.js:16:9)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
Compilation failed
npm WARN @angular/core@2.4.2 requires a peer of rxjs@^5.0.1 but none was installed.
npm WARN @angular/core@2.4.2 requires a peer of zone.js@^0.7.2 but none was installed.
npm ERR! Linux 3.2.0-23-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.9.4
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE

npm ERR! ng2-uploader@1.5.7 postinstall: `ngc -p tsconfig.json`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ng2-uploader@1.5.7 postinstall script 'ngc -p tsconfig.json'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ng2-uploader package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ngc -p tsconfig.json
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ng2-uploader
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ng2-uploader
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /vagrant/npm-debug.log
vagrant@precise64:/vagrant$sudo npm安装
>ng2-uploader@1.5.7postinstall/vagrant/node_模块/ng2上传器
>ngc-p tsconfig.json
错误:错误无法找到“节点”的类型定义文件。
在Object.check(/vagrant/node_modules/@angular/compiler cli/node_modules/@angular/tsc wrapped/src/tsc.js:31:15)
在Object.main(/vagrant/node_modules/@angular/compiler cli/node_modules/@angular/tsc wrapped/src/main.js:26:15)
反对。(/vagrant/node_modules/@angular/compiler cli/src/main.js:16:9)
在模块处编译(Module.js:570:32)
在Object.Module.\u extensions..js(Module.js:579:10)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
位于Module.runMain(Module.js:604:10)
运行时(bootstrap_node.js:394:7)
编译失败
npm警告@角度/core@2.4.2需要rxjs@^5.0.1的对等机,但未安装任何对等机。
npm警告@角度/core@2.4.2需要zone.js@^0.7.2的对等机,但未安装任何对等机。
npm错误!Linux 3.2.0-23-generic
npm错误!argv“/usr/bin/nodejs”“/usr/bin/npm”“安装”
npm错误!节点v6.9.4
npm错误!npm v4.0.5
npm错误!代码失效循环
npm错误!ng2-uploader@1.5.7postinstall:`ngc-p tsconfig.json`
npm错误!退出状态1
npm错误!
npm错误!在ng2上失败-uploader@1.5.7安装后脚本“ngc-p tsconfig.json”。
npm错误!确保已安装最新版本的node.js和npm。
npm错误!如果您这样做,这很可能是ng2上传程序包的问题,
npm错误!与npm本身无关。
npm错误!告诉作者此操作在您的系统上失败:
npm错误!ngc-p tsconfig.json
npm错误!您可以通过以下方式获取有关如何打开此项目问题的信息:
npm错误!npm bugs ng2上传程序
npm错误!或者,如果不可用,您可以通过以下方式获取他们的信息:
npm错误!npm所有者ls ng2上传器
npm错误!上面可能还有其他日志输出。
npm错误!请在任何支持请求中包括以下文件:
npm错误/vagrant/npm-debug.log
更新:我认为这可能与Angular cli安装不正确有关。。。(仍然不知道如何修复此问题)

vagrant@precise64:/vagrant$ng帮助
找不到模块“autoprefixer”
错误:找不到模块“autoprefixer”
在Function.Module.\u解析文件名(Module.js:469:15)
在Function.Module.\u加载(Module.js:417:25)
at Module.require(Module.js:497:17)
根据需要(内部/module.js:20:19)
反对。(/vagrant/node_modules/angular cli/models/webpack build common.js:7:20)
在模块处编译(Module.js:570:32)
在Object.Module.\u extensions..js(Module.js:579:10)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
at Module.require(Module.js:497:17)
根据需要(内部/module.js:20:19)
反对。(/vagrant/node_modules/angular cli/models/index.js:5:10)
在模块处编译(Module.js:570:32)
在Object.Module.\u extensions..js(Module.js:579:10)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
at Module.require(Module.js:497:17)
根据需要(内部/module.js:20:19)
反对。(/vagrant/node_modules/angular cli/models/webpack config.js:5:10)
在模块处编译(Module.js:570:32)
在Object.Module.\u extensions..js(Module.js:579:10)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
at Module.require(Module.js:497:17)
根据需要(内部/module.js:20:19)
反对。(/vagrant/node_modules/angular cli/tasks/build webpack.js:6:24)
在模块处编译(Module.js:570:32)
在Object.Module.\u extensions..js(Module.js:579:10)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
at Module.require(Module.js:497:17)
根据需要(内部/module.js:20:19)
反对。(/vagrant/node_modules/angular cli/commands/build.js:3:23)
在模块处编译(Module.js:570:32)
在Object.Module.\u extensions..js(Module.js:579:10)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
at Module.require(Module.js:497:17)
根据需要(内部/module.js:20:19)
at Class.included命令(/vagrant/node_modules/angular cli/addon/index.js:21:16)
at/vagrant/node_modules/angular cli/angular cli/lib/models/project.js:392:61
at Array.forEach(本机)
在Project.addonCommand(/vagrant/node_modules/angular cli/angular cli/lib/models/Project.js:391:15)
在Project.eachaddon命令(/vagrant/node_modules/angular cli/angular cli/lib/models/Project.js:426:30)
在module.exports(/vagrant/node_modules/angular cli/angular cli/lib/cli/lookup command.js:33:13)
在CLI。(/vagrant/node_modules/angular cli/angular cli/lib/cli/cli.js:34:26)
在tryCatch(/vagrant/node_modules/angular cli/node_modules/rsvp/dist/lib/rsvp/-internal.js:215:12)
在invokeCallback(/vagrant/node_modules/angular cli/node_modules/rsvp/dist/lib/rsvp/-internal.js:230:13)
发布时(/vagrant/node_modules/angular cli/node_modules/rsvp/dist/lib/rsvp/-internal.js:198:7)
刷新时(/vagrant/node_modules/angular cli/node_modules/rsvp/dist/lib/rsvp/asap.js:85:5)
at_combinedTickCallback(内部/流程/下一步勾选js:67:7)
在进程中。_tick回调(内部/process/next_tick.js:98:9)

您的问题是vagrant以root用户的身份运行了您的配置脚本,因此所有内容都已完成
vagrant@precise64:/vagrant$ ng help
Cannot find module 'autoprefixer'
Error: Cannot find module 'autoprefixer'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/vagrant/node_modules/angular-cli/models/webpack-build-common.js:7:20)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/vagrant/node_modules/angular-cli/models/index.js:5:10)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/vagrant/node_modules/angular-cli/models/webpack-config.js:5:10)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/vagrant/node_modules/angular-cli/tasks/build-webpack.js:6:24)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/vagrant/node_modules/angular-cli/commands/build.js:3:23)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Class.includedCommands (/vagrant/node_modules/angular-cli/addon/index.js:21:16)
    at /vagrant/node_modules/angular-cli/angular-cli/lib/models/project.js:392:61
    at Array.forEach (native)
    at Project.addonCommands (/vagrant/node_modules/angular-cli/angular-cli/lib/models/project.js:391:15)
    at Project.eachAddonCommand (/vagrant/node_modules/angular-cli/angular-cli/lib/models/project.js:426:30)
    at module.exports (/vagrant/node_modules/angular-cli/angular-cli/lib/cli/lookup-command.js:33:13)
    at CLI.<anonymous> (/vagrant/node_modules/angular-cli/angular-cli/lib/cli/cli.js:34:26)
    at tryCatch (/vagrant/node_modules/angular-cli/node_modules/rsvp/dist/lib/rsvp/-internal.js:215:12)
    at invokeCallback (/vagrant/node_modules/angular-cli/node_modules/rsvp/dist/lib/rsvp/-internal.js:230:13)
    at publish (/vagrant/node_modules/angular-cli/node_modules/rsvp/dist/lib/rsvp/-internal.js:198:7)
    at flush (/vagrant/node_modules/angular-cli/node_modules/rsvp/dist/lib/rsvp/asap.js:85:5)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
Vagrant.configure("2") do |config|
    config.vm.box = "hashicorp/precise64"

    config.vm.provision :shell, path: "vagrant-provision-npm-angular-2.sh", privileged: "false"

end