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`

六、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中vuevue-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

持续更新……

  • 11
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
你在使用nvm下载npm报错的问题可能是由于以下原因导致的: 1. 首先,你需要检查是否正确安装了nvm管理包。你可以前往。 2. 其次,你可能遇到了npm安装失败的问题。有时,npm安装失败是因为缺少必要的配置文件。你可以在nvm文件夹下的settings.txt文件中添加以下两行内容,并保存: ``` node_mirror: https://npm.taobao.org/mirrors/node/ npm_mirror: https://npm.taobao.org/mirrors/npm/ ``` 之后,你可以卸载之前安装的node,并重新安装node [1。 3. 最后,如果你已经成功通过nvm安装了一个node版本,但发现npm并没有安装成功,可能是因为该node版本不带npm包。你可以尝试安装其他版本的node。你可以使用以下命令安装第二个node版本: ``` nvm install <node_version> ``` 安装完成后,你应该能够成功安装npm [2。 希望以上建议对你解决nvm下载npm报错的问题有所帮助。如果仍有疑问,请随时向我提问。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [使用nvm管理node版本,npm安装失败解决方法](https://blog.csdn.net/weixin_46653360/article/details/127936919)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *2* [使用nvm下载node版本之后,输入npm报错:“npm”不是内部或外部命令,也不是可运行的程序或批处理文件(nvm...](https://blog.csdn.net/m0_50744582/article/details/131023971)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值