npm报错
目錄
一、問題:404 Not Found - GET https://registry.npmjs.org/** - Not found
二、問題:yarn : 無法加載文件 C:\Users\**\AppData\Roaming\npm\yarn.ps1,因為在此系統上禁止運行腳本。
三、問題:error An unexpected error occurred: "http://npm.company.com/**/-/**-3.26.17.tgz: unexpected end of file".
四、yarn dev:cross-env CODE_ENV=local cooking watch -p 'cooking' 不是內部或外部命令,也不是可運行的程序或批處理文件。
五、npm ERR! xxx@0.1.0 dev: `cross-env CODE_ENV=dev vue-cli-service build
記錄使用npm時各類報錯
一、問題:404 Not Found - GET https://registry.npmjs.org/** - Not found
npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/**-core - Not found npm ERR! 404 npm ERR! 404 '**-core@1.7.7' is not in the npm registry. npm ERR! 404 You should bug the author to publish it (or use the name yourself!) npm ERR! 404 npm ERR! 404 tarball, folder, http url, or git url. npm ERR! C:\Users\***\AppData\Roaming\npm-cache\_logs\2021-07-26T03_12_06_731Z-debug.log解決方案:?
?1、查看一下是否設置代理:
npm config set proxy npm config get https-proxy2、以上兩個命令如果返回null,那么就不需要執行以下命令清理:
npm config set https-proxy null npm config get proxy null3、重新設置:
npm config set registry https://registry.npmjs.org/若無效,則嘗試:
npm config set registry https://skimdb.npmjs.com/registry或者如果不起作用,請嘗試 GitHub 鏈接:
npm config set registry https://github.com/npm/npm-registry-couchapp二、問題:yarn : 無法加載文件 C:\Users\**\AppData\Roaming\npm\yarn.ps1,因為在此系統上禁止運行腳本。
yarn : 無法加載文件 C:\Users\**\AppData\Roaming\npm\yarn.ps1,因為在此系統上禁止運行 腳本。有關詳細信息,請參閱 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Executi on_Policies。 所在位置 行:1 字符: 1 + yarn dev + ~~~~+ CategoryInfo : SecurityError: (:) [],PSSecurityException+ FullyQualifiedErrorId : UnauthorizedAccess解決方案:?
1、搜索cmd,以管理員方式運行powershell
2、使用命令更改計算機的執行策略:set-ExecutionPolicy RemoteSigned
3、查看當前執行策略:
PS C:\windows\system32> get-ExecutionPolicy RemoteSigned三、問題:error An unexpected error occurred: "http://npm.company.com/**/-/**-3.26.17.tgz: unexpected end of file".
error An unexpected error occurred: "http://npm.company.com/**/-/**-3.26.17.tgz: unexpected end of file". info If you think this is a bug, please open a bug report with the information provided in "D:\\code\\**\\**\\yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. info There appears to be trouble with your network connection. Retrying...解決方案:
配置公司鏡像源
nrm add **如果執行報錯,參考?nrm 安裝完成但 throw new ERR_INVALID_ARG_TYPE(name, ‘string‘, value);_a806488840的博客-CSDN博客
四、yarn dev:cross-env CODE_ENV=local cooking watch -p 'cooking' 不是內部或外部命令,也不是可運行的程序或批處理文件。
PS D:\code\**\**-Frontend> yarn dev yarn run v1.22.10 $ cross-env CODE_ENV=local cooking watch -p 'cooking' 不是內部或外部命令,也不是可運行的程序 或批處理文件。嘗試解決:
npm install -g cooking npm install -g cooking-cli后又報錯:
$ cross-env CODE_ENV=local cooking watch -p[cooking@1.5.4] - chalk.yellow('permission denied')Try running with sudo or get accesssudo chown -R $USER:$(id -gn $USER) C:\Users\**\.cookingerror Command failed with exit code 1.解決方案:
原node版本為14.17.3,切換為12.22.1就不報錯了……
nvm use 12.22.1五、npm ERR! xxx@0.1.0 dev: `cross-env CODE_ENV=dev vue-cli-service build`
npm run dev報錯:ERROR Build failed with errors. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! quality-measure@1.0.98 deploy_dev: `cross-env CODE_ENV=dev vue-cli-service build && ymm_upload -r ./dist -n qualityMeasure -t dev -z 0 -f 1` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the quality-measure@1.0.98 deploy_dev 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 ERR! /data/jenkins/.npm/_logs/2022-02-28T06_35_38_029Z-debug.log解決方案:
package.json中vue與vue-template-compiler版本不一致導致,重新下一個同版本包就可以了
"vue": "^2.5.21", "vue-template-compiler": "^2.5.21"持續更新……
總結
- 上一篇: 网页编写练习 小米闪购
- 下一篇: 网络流之最大流问题