npm报错
目录
一、问题:404 Not Found - GET https://registry.npmjs.org/** - Not found
二、问题:yarn : 无法加载文件 C:\Users\**\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本。
四、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`
六、Error: EPERM: operation not permitted, lstat ''
记录使用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-proxy
2、以上两个命令如果返回null,那么就不需要执行以下命令清理:
npm config set https-proxy null
npm config get proxy null
3、重新设置:
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
PS C:\windows\system32> set-ExecutionPolicy RemoteSigned
执行策略更改
执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暂停(S) [?] 帮助 (默认值为“N”): y
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 access
sudo chown -R $USER:$(id -gn $USER) C:\Users\**\.cooking
error 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"
六、Error: EPERM: operation not permitted, lstat ''
npm install报错:
error code EPERM
error syscall lstat
error path D:\code\snake\amh-mindmap-editor\node_modules\.staging\echarts-1f2fabae\dist\echarts.common.min.js
error errno -4048
error Error: EPERM: operation not permitted, lstat 'D:\code\snake\amh-mindmap-editor\node_modules\.staging\echarts-1f2fabae\dist\echarts.common.min.js'
error { [Error: EPERM: operation not permitted, lstat 'D:\code\snake\amh-mindmap-editor\node_modules\.staging\echarts-1f2fabae\dist\echarts.common.min.js']
error cause:
error { Error: EPERM: operation not permitted, lstat 'D:\code\snake\amh-mindmap-editor\node_modules\.staging\echarts-1f2fabae\dist\echarts.common.min.js'
error errno: -4048,
error code: 'EPERM',
error syscall: 'lstat',
error path:
error 'D:\\code\\snake\\amh-mindmap-editor\\node_modules\\.staging\\echarts-1f2fabae\\dist\\echarts.common.min.js' },
error stack:
error 'Error: EPERM: operation not permitted, lstat \'D:\\code\\snake\\amh-mindmap-editor\\node_modules\\.staging\\echarts-1f2fabae\\dist\\echarts.common.min.js\'',
error errno: -4048,
error code: 'EPERM',
error syscall: 'lstat',
error path:
error 'D:\\code\\snake\\amh-mindmap-editor\\node_modules\\.staging\\echarts-1f2fabae\\dist\\echarts.common.min.js',
error parent: 'amh-mindmap-editor' }
error The operation was rejected by your operating system.
error It's possible that the file was already in use (by a text editor or antivirus),
error or that you lack permissions to access it.
error
error If you believe this might be a permissions issue, please double-check the
error permissions of the file and its containing directories, or try running
error the command again as root/Administrator.
verbose exit [ -4048, true ]
解决方案:npm install安装失败,报错记录之The operation was rejected by your operating system.
尝试方法二、三后出现四报错
npm install 日志
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
> uws@9.14.0 install D:\code\snake\amh-mindmap-editor\node_modules\uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0
> node-sass@4.14.1 install D:\code\snake\amh-mindmap-editor\node_modules\node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/win32-x64-64_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.14.1/win32-x64-64_binding.node":
read ECONNRESET
Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.
export HTTP_PROXY=http://example.com:1234
or configure npm proxy via
npm config set proxy http://example.com:8080
> phantomjs-prebuilt@2.1.16 install D:\code\snake\amh-mindmap-editor\node_modules\phantomjs-prebuilt
> node install.js
PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip
Saving to C:\Users\TONG~1.SHE\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip
Receiving...
Error making request.
Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:111:27)
sass版本问题,注意不能直接npm i node-sass,一定要重新设置一个源,不然还是报错。
npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
npm i node-sass
持续更新……
更多推荐
所有评论(0)