我目前正在研究thinkster.io教程,并在成功构建后端后继续编程前端。我正在使用一个使用vagrant自动配置的VM,我通过ssh访问它,并使我的本地HDD的一部分与VM的HDD的一部分同步(如果相关)。
我开始时:
sudo apt-get install nodejs
sudo apt-get install build-essential
npm install -g @angular/cli
然后浏览到frontend-folder(package.json所在的位置)并运行
npm install
只是受到这个错误的欢迎:
npm WARN deprecated angular-cli@1.0.0-beta.15: angular-cli has been renamed to @angular/cli. Please update your dependencies.
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
ang2-conduit@0.0.0 /vagrant/thinkster/angular2-realworld-example-app
├── UNMET PEER DEPENDENCY @angular/compiler@2.0.0
└── UNMET PEER DEPENDENCY @angular/core@2.0.0
npm WARN @angular/compiler-cli@4.4.6 requires a peer of @angular/compiler@4.4.6 but none was installed.
npm WARN @angular/compiler-cli@4.4.6 requires a peer of @angular/core@4.4.6 but none was installed.
npm WARN @angular/platform-server@2.4.10 requires a peer of @angular/core@2.4.10 but none was installed.
npm WARN @angular/platform-server@2.4.10 requires a peer of @angular/common@2.4.10 but none was installed.
npm WARN @angular/platform-server@2.4.10 requires a peer of @angular/compiler@2.4.10 but none was installed.
npm WARN @angular/platform-server@2.4.10 requires a peer of @angular/platform-browser@2.4.10 but none was installed.
npm WARN @angular/tsc-wrapped@4.4.6 requires a peer of typescript@^2.1.5 but none was installed.
npm WARN string-replace-loader@1.3.0 requires a peer of webpack@1 || 2 || 3 but none was installed.
npm WARN tsickle@0.21.6 requires a peer of typescript@^2.1.0 but none was installed.
npm WARN webpack-dev-middleware@1.12.0 requires a peer of webpack@^1.0.0 || ^2.0.0 || ^3.0.0 but none was installed.
npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/compiler@2.0.2 but none was installed.
npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/platform-server@2.0.2 but none was installed.
npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/core@2.0.2 but none was installed.
npm ERR! Linux 4.9.0-3-amd64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v6.11.4
npm ERR! npm v3.10.10
npm ERR! path /vagrant/thinkster/angular2-realworld-example-app/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/sshpk/bin/sshpk-conv
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/vagrant/thinkster/angular2-realworld-example-app/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/sshpk/bin/sshpk-conv'
npm ERR! enoent ENOENT: no such file or directory, chmod '/vagrant/thinkster/angular2-realworld-example-app/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/sshpk/bin/sshpk-conv'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /vagrant/thinkster/angular2-realworld-example-app/npm-debug.log
npm ERR! code 1
我尝试过在网上找到的各种东西,但似乎没有任何帮助。我对npm不太熟悉,因此我很难让它运作起来。有人可以帮忙吗?
这是 package.json:
{
"name": "ang2-conduit",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"core-js": "^2.4.1",
"marked": "^0.3.6",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"@types/jasmine": "^2.2.30",
"@types/marked": "0.0.28",
"angular-cli": "1.0.0-beta.15",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.5",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2"
}
}
答案 0 :(得分:1)
我认为你在流浪汉VM上?我的猜测是你将项目存储在一个带有Windows主机的共享文件夹中。我看到模块失败的是请求,这在很多情况下直接在Windows或共享文件夹中使我失败。
最好的办法是,如果你真的在一个流浪汉的虚拟机上,就是将一个VM文件夹挂载到node_modules上。这将确保符号链接和链接按预期工作,因为它们将保留在同一系统上。
要实现此目的,请将SSH连接到VM,然后运行以下行:
sudo mkdir -p /app_node_modules
sudo mount --bind /app_node_modules /vagrant/thinkster/angular2-realworld-example-app/node_modules
您必须知道npm安装正在基于unix的系统上执行所有任务,而托管文件的文件夹托管在具有不同功能的不同类型的系统上。
上找到了可能的解决方法我在npm 4.1.2中遇到了类似的问题,之后就消失了 更新到最新的4.6.1。此问题还有一个解决方法: npm install --no-bin-links;在这种情况下,npm不会尝试chmod 这些文件。
答案 1 :(得分:0)
尝试更新依赖项并使用-g参数或--global执行这些依赖项的npm安装,然后尝试运行npm run命令。