镜面王子
镜面王子
  • 发布:2021-11-01 22:46
  • 更新:2021-11-01 22:46
  • 阅读:1912

【报Bug】ubuntu在vue-cli创建项目时,提示Missing script: "dev:h5"

分类:uni-app

产品分类: uniapp/H5

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: ubuntu20.04

浏览器平台: Chrome

浏览器版本: 90.0.4430.212(正式版本(64 位)

项目创建方式: CLI

CLI版本号: yarn v1.22.15

示例代码:

在my-project里面的node_modules只有两个文件夹@dcloudioregenerator-runtime

package.js文件

{  
  "name": "my-project",  
  "version": "0.1.0",  
  "private": true,  
  "dependencies": {  
    "@dcloudio/uni-helper-json": "*",  
    "regenerator-runtime": "^0.12.1"  
  },  
  "devDependencies": {  
    "@babel/runtime": "~7.12.0",  
    "@dcloudio/types": "*",  
    "@dcloudio/vue-cli-plugin-hbuilderx": "^2.0.0-22420190823018",  
    "@dcloudio/vue-cli-plugin-uni": "^2.0.0-22420190823018",  
    "@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.0-22420190823018",  
    "@vue/cli-plugin-babel": "~4.5.0",  
    "@vue/cli-service": "~4.5.0",  
    "mini-types": "*",  
    "miniprogram-api-typings": "*",  
    "postcss-comment": "^2.0.0"  
  }  
}

postcss.config.js

const path = require('path')  
module.exports = {  
  parser: require('postcss-comment'),  
  plugins: [  
    require('postcss-import')({  
      resolve (id, basedir, importOptions) {  
        if (id.startsWith('~@/')) {  
          return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))  
        } else if (id.startsWith('@/')) {  
          return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))  
        } else if (id.startsWith('/') && !id.startsWith('//')) {  
          return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))  
        }  
        return id  
      }  
    }),  
    require('autoprefixer')({  
      remove: process.env.UNI_PLATFORM !== 'h5'  
    }),  
    require('@dcloudio/vue-cli-plugin-uni/packages/postcss')  
  ]  
}

操作步骤:

/www/constellation # npm -v  
8.1.0  
/www/constellation # node -v  
v16.13.0  
/www/constellation # cat /proc/version  
Linux version 5.11.0-34-generic (buildd@lgw01-amd64-001) (gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #36~20.04.1-Ubuntu SMP Fri Aug 27 08:06:32 UTC 2021  
/www/constellation #  npm get registry  
https://registry.npm.taobao.org/  
/www/constellation # npm install -g @vue/cli  
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained  
npm WARN deprecated har-validator@5.1.5: this library is no longer supported  
npm WARN deprecated apollo-tracing@0.15.0: The `apollo-tracing` package is no longer part of Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#tracing for details  
npm WARN deprecated graphql-extensions@0.15.0: The `graphql-extensions` API has been removed from Apollo Server 3. Use the plugin API instead: https://www.apollographql.com/docs/apollo-server/integrations/plugins/  
npm WARN deprecated @hapi/address@2.1.4: This version has been deprecated and is no longer supported or maintained  
npm WARN deprecated apollo-cache-control@0.14.0: The functionality provided by the `apollo-cache-control` package is built in to `apollo-server-core` starting with Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#cachecontrol for details.  
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained  
npm WARN deprecated @hapi/joi@15.1.1: joi is leaving the @hapi organization and moving back to 'joi' (https://github.com/sideway/joi/issues/2411)  
npm WARN deprecated graphql-tools@4.0.8: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as @graphql-tools/schema, @graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead  

changed 944 packages in 24s  

9 packages are looking for funding  
  run `npm fund` for details  
/www/constellation # vue create -p dcloudio/uni-preset-vue my-project  
Fetching remote preset dcloudio/uni-preset-vue...  

Vue CLI v4.5.15  
✨  Creating project in /www/constellation/my-project.  
⚙️  Installing CLI plugins. This might take a while...  

yarn install v1.22.15  
info No lockfile found.  
[1/4] Resolving packages...  
[2/4] Fetching packages...  
info fsevents@2.3.2: The platform "linux" is incompatible with this module.  
info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.  
info fsevents@1.2.13: The platform "linux" is incompatible with this module.  
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.  
[3/4] Linking dependencies...  
[4/4] Building fresh packages...  

success Saved lockfile.  
Done in 13.09s.  

预期结果:

如何才能成功的有运行 npm run dev:h5

实际结果:
/www/constellation/my-project # npm run dev:h5  
npm ERR! Missing script: "dev:h5"  
npm ERR!   
npm ERR! To see a list of scripts, run:  
npm ERR!   npm run  

npm ERR! A complete log of this run can be found in:  
npm ERR!     /root/.npm/_logs/2021-11-01T14_34_09_965Z-debug.log

bug描述:

系统是在ubuntu 20.04

/www/constellation/my-project # yarn serve  
yarn run v1.22.15  
error Command "serve" not found.  
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.  
/www/constellation/my-project # npm run dev:h5  
npm ERR! Missing script: "dev:h5"  
npm ERR!   
npm ERR! To see a list of scripts, run:  
npm ERR!   npm run  

npm ERR! A complete log of this run can be found in:  
npm ERR!     /root/.npm/_logs/2021-11-01T14_34_09_965Z-debug.log  
0 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'dev:h5' ]  
1 info using npm@8.1.0  
2 info using node@v16.13.0  
3 timing npm:load:whichnode Completed in 0ms  
4 timing config:load:defaults Completed in 1ms  
5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms  
6 timing config:load:builtin Completed in 1ms  
7 timing config:load:cli Completed in 1ms  
8 timing config:load:env Completed in 0ms  
9 timing config:load:file:/www/constellation/my-project/.npmrc Completed in 0ms  
10 timing config:load:project Completed in 1ms  
11 timing config:load:file:/root/.npmrc Completed in 1ms  
12 timing config:load:user Completed in 1ms  
13 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms  
14 timing config:load:global Completed in 0ms  
15 timing config:load:validate Completed in 1ms  
16 timing config:load:credentials Completed in 1ms  
17 timing config:load:setEnvs Completed in 0ms  
18 timing config:load Completed in 7ms  
19 timing npm:load:configload Completed in 7ms  
20 timing npm:load:setTitle Completed in 0ms  
21 timing npm:load:setupLog Completed in 1ms  
22 timing config:load:flatten Completed in 2ms  
23 timing npm:load:cleanupLog Completed in 1ms  
24 timing npm:load:configScope Completed in 0ms  
25 timing npm:load:projectScope Completed in 0ms  
26 timing npm:load Completed in 12ms  
27 timing command:run-script Completed in 5ms  
28 verbose stack Error: Missing script: "dev:h5"  
28 verbose stack  
28 verbose stack To see a list of scripts, run:  
28 verbose stack   npm run  
28 verbose stack     at RunScript.run (/usr/local/lib/node_modules/npm/lib/run-script.js:105:13)  
29 verbose cwd /www/constellation/my-project  
30 verbose Linux 5.11.0-34-generic  
31 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev:h5"  
32 verbose node v16.13.0  
33 verbose npm  v8.1.0  
34 error Missing script: "dev:h5"  
34 error  
34 error To see a list of scripts, run:  
34 error   npm run  
35 verbose exit 1  
2021-11-01 22:46 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复