我正在使用 VSCode 并且: 节点 v16.13.2 npm 8.15.0
我只是构建了一个 Angular 项目并一一安装依赖项,一切都很顺利。
重现问题的cmd:
ng new demo-app
# built was with routing & scss
cd demo-app
npm install primeng --save
npm install primeicons --save
npm install bootstrap --save
npm install @angular/material --save
npm install @angular/cdk --save
# now it is still fine to npm start
del /f/s/q node_modules & rmdir node_modules
npm install
# The error occurs
虽然其他人在没有“node_module”文件夹的情况下下载我的项目,并尝试“npm install”这些依赖项,但它已经威胁到来自node-gyp的错误:> python is not found。
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: We have news to share - Protractor is deprecated and will reach end-of-life by Summer 2023. To learn more and find out about other options please refer to this post on the Angular blog. Thank you for using and contributing to Protractor. https://goo.gle/state-of-e2e-in-angular
npm ERR! code 1
npm ERR! path C:\Users\zhoujoh\Downloads\temp\angular-demo\node_modules\fibers
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c C:\temp\install-cf48aa97.cmd
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
这很奇怪,因为我没有包含任何与 python 相关的内容。
然后我只是按照安装Python它说找不到VS或C++的东西。
npm ERR! gyp ERR! find VS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
然后我就卡在这个地方了。
我终于通过跳过脚本解决了这个问题:npm install --ignore-scripts
但是所有正常项目都应该这样做吗?或者我应该安装所有这些东西... python c++, VS2017 ...?
如果有什么想法请帮忙,非常感谢
如果我只想为正常项目进行正常的“npm install”,我希望如何处理,谢谢。
我的package.json
{
"name": "angular-demo",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --port=4202 --open",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^14.2.0",
"@angular/cdk": "^14.2.6",
"@angular/common": "^14.2.0",
"@angular/compiler": "^14.2.0",
"@angular/core": "^14.2.0",
"@angular/forms": "^14.2.0",
"@angular/material": "^14.2.6",
"@angular/platform-browser": "^14.2.0",
"@angular/platform-browser-dynamic": "^14.2.0",
"@angular/router": "^14.2.0",
"bootstrap": "^5.2.2",
"primeicons": "^6.0.1",
"primeng": "^14.1.2",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^14.2.2",
"@angular/cli": "~14.2.2",
"@angular/compiler-cli": "^14.2.0",
"@types/jasmine": "~4.0.0",
"jasmine-core": "~4.3.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"typescript": "~4.7.2"
}
}
有关您的软件包的某些内容认为它需要使用 gyp 进行本机构建。
您可以让链中的下一个用户尝试:
npm install --global windows-build-tools
但是,通过检查为什么你的依赖树认为 anguar 项目需要 node-gyp 可能会更好。