尝试在项目中安装依赖项时出错
我在 node 和 angular 中安装了一个简单的项目,以学习一些关于 jasmin 测试的知识。因此,在下载和安装配置的开始阶段,我在进行 npm 安装时遇到了这个问题:
node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error self signed certificate in certificate chain
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack at TLSSocket.onConnectSecure (_tls_wrap.js:1473:34)
gyp ERR! stack at TLSSocket.emit (events.js:311:20)
gyp ERR! stack at TLSSocket._finishInit (_tls_wrap.js:916:8)
gyp ERR! stack at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:686:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\s018150\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=D:\\Alura\\alura_testes_angular\\api\\node_modules\\sqlite3\\lib\\binding\\node-v72-win32-x64\\node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=D:\\Alura\\alura_testes_angular\\api\\node_modules\\sqlite3\\lib\\binding\\node-v72-win32-x64" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72" "--python=C:\\Python27\\pythonw.exe"
gyp ERR! cwd D:\Alura\alura_testes_angular\api\node_modules\sqlite3
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v7.0.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\s018150\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=D:\Alura\alura_testes_angular\api\node_modules\sqlite3\lib\binding\node-v72-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=D:\Alura\alura_testes_angular\api\node_modules\sqlite3\lib\binding\node-v72-win32-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72 --python=C:\Python27\pythonw.exe' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (D:\Alura\alura_testes_angular\api\node_modules\sqlite3\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:311:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Windows_NT 10.0.16299
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\Alura\\alura_testes_angular\\api\\node_modules\\sqlite3\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd D:\Alura\alura_testes_angular\api\node_modules\sqlite3
node-pre-gyp ERR! node -v v12.16.1
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\s018150\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=D:\Alura\alura_testes_angular\api\node_modules\sqlite3\lib\binding\node-v72-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=D:\Alura\alura_testes_angular\api\node_modules\sqlite3\lib\binding\node-v72-win32-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72 --python=C:\Python27\pythonw.exe' (1)
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error self signed certificate in certificate chain
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack at TLSSocket.onConnectSecure (_tls_wrap.js:1473:34)
gyp ERR! stack at TLSSocket.emit (events.js:311:20)
gyp ERR! stack at TLSSocket._finishInit (_tls_wrap.js:916:8)
gyp ERR! stack at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:686:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\s018150\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=D:\\Alura\\alura_testes_angular\\api\\node_modules\\sqlite3\\lib\\binding\\node-v72-win32-x64\\node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=D:\\Alura\\alura_testes_angular\\api\\node_modules\\sqlite3\\lib\\binding\\node-v72-win32-x64" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72" "--python=C:\\Python27\\pythonw.exe"
gyp ERR! cwd D:\Alura\alura_testes_angular\api\node_modules\sqlite3
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v7.0.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\s018150\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=D:\Alura\alura_testes_angular\api\node_modules\sqlite3\lib\binding\node-v72-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=D:\Alura\alura_testes_angular\api\node_modules\sqlite3\lib\binding\node-v72-win32-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72 --python=C:\Python27\pythonw.exe' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (D:\Alura\alura_testes_angular\api\node_modules\sqlite3\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:311:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Windows_NT 10.0.16299
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\Alura\\alura_testes_angular\\api\\node_modules\\sqlite3\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd D:\Alura\alura_testes_angular\api\node_modules\sqlite3
node-pre-gyp ERR! node -v v12.16.1
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\s018150\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=D:\Alura\alura_testes_angular\api\node_modules\sqlite3\lib\binding\node-v72-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=D:\Alura\alura_testes_angular\api\node_modules\sqlite3\lib\binding\node-v72-win32-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72 --python=C:\Python27\pythonw.exe' (1)
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
我尝试了一些命令,例如
npm install sqlite3
或
npm install sqlite3 --fallback-to-build
。而且,我还更新了 npm 版本,删除了 node_modules 目录,然后再次安装了所有内容,但出现了相同的错误消息。
我的 package.json 文件是:
{
"name": "alurapic",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.2",
"cors": "^2.8.4",
"cryptiles": ">=4.1.2",
"express": "^4.16.3",
"jimp": "^0.2.28",
"jsonwebtoken": "^8.2.0",
"multer": "^1.3.0",
"node-pre-gyp": "^0.15.0",
"sqlite3": "^4.1.0",
"uuid": "^3.2.1"
}
}
>
您可以尝试以下命令吗?
NODE_TLS_REJECT_UNAUTHORIZED=0 npm install
或者,如果在 Windows 下,则尝试两个命令
set NODE_TLS_REJECT_UNAUTHORIZED=0
npm install
我也遇到过同样的问题。
已解决并对我有用:
-
在环境变量中定义 python。
-
删除 node_modules 和 package-lock.json
-
npm i [email protected]
-
npm i
-
npm start
我正在使用 v14.13.0 版本的 node
我的环境
Angular CLI: 10.1.3 Node:14.13.0 操作系统:win32 x64
*Angular:
Ivy Workspace: 软件包版本
@angular-devkit/architect 0.1001.3(仅限 cli)
@angular-devkit/core 10.1.3(仅限 cli)
@angular-devkit/schematics 10.1.3(仅限 cli)
@schematics/angular 10.1.3(仅限 cli)
@schematics/update 0.1001.3(仅限 cli)*