【发布时间】:2020-04-10 04:04:08
【问题描述】:
我有一个小的 bash 脚本,它下载并提取 node.js,然后尝试运行 npm install(是的,我已经阅读了关于 nvm 但想了解这个问题)
build.sh
NODE_VERSION='v10.0.0'
NODE_FOLDER="node-${NODE_VERSION}-linux-x64"
NODE_ARCHIVE="${NODE_FOLDER}.tar.gz"
NODE_DOWNLOAD_URL="https://nodejs.org/dist/${NODE_VERSION}/${NODE_ARCHIVE}"
wget "${NODE_DOWNLOAD_URL}"
tar -xf ${NODE_ARCHIVE}
export NODE_PATH="${NODE_FOLDER}/bin"
export PATH=$NODE_PATH:$PATH
node --version
npm --version
npm install
当我运行上面的脚本时,我安装了部分依赖项,但在某些时候它失败了:
v10.0.0
5.6.0
> yorkie@1.0.3 install /home/user/repos/webapp/webapp-frontend-vue-cli/node_modules/yorkie
> node bin/install.js
sh: 1: node: not found
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! yorkie@1.0.3 install: `node bin/install.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the yorkie@1.0.3 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 ERR! /home/user/.npm/_logs/2019-12-17T15_48_53_166Z-debug.log
还有 package.json 文件:
{
"name": "webapp-frontend-vue-cli",
"version": "1.0.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"vue": "^2.6.10",
"vue-router": "^3.1.3",
"vuetify": "^2.1.7"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.0-beta.15",
"@vue/cli-plugin-eslint": "^3.0.0-beta.15",
"@vue/cli-service": "^3.0.0-beta.15",
"browser-sync": "^2.24.4",
"browser-sync-webpack-plugin": "^2.2.2",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-vue": "^4.5.0",
"vue-template-compiler": "^2.6.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
关于错误的任何建议 - npm 和 node 都可以在运行脚本的当前 shell 中找到。
【问题讨论】:
-
你确定是“node”而不是“nodejs”吗?