错误:无法找到相对于目录“/ app”

时间:2017-10-27 16:38:50

标签: babeljs babel deis babel-loader helmet.js

在我的Deis应用中收到错误;将Helmet引入frontend middleware。该应用程序最初基于React Boilerplate和我运行的大多数建议,我已经在源代码中实现/探索,并且仍然产生这个“幻像”错误。

在Deis应用实例上发生;在本地重现这些步骤时,完成(生产)构建过程没有问题。

当然,我可以从中间件中删除helmet,但是,我宁愿不...

错误输出:

> pkg-name@0.0.1 start /app
> npm run start:production

> pkg-name@0.0.1 start:production /app
> npm run build && npm run start:prod

> pkg-name@0.0.1 build /app
> cross-env NODE_ENV=production webpack --config internals/webpack/webpack.prod.babel.js --color -p --progress

/app/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328
        throw e;
        ^
2017-10-27T15:50:48+00:00 deis-app-name[]:
Error: Couldn't find preset "latest" relative to directory "/app"
    at /app/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (/app/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/app/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/app/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/app/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/app/node_modules/babel-register/lib/node.js:103:45)
    at loader (/app/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/app/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:531:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pkg-name@0.0.1 build: `cross-env NODE_ENV=production webpack --config internals/webpack/webpack.prod.babel.js --color -p --progress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pkg-name@0.0.1 build script.

依赖对象值/对:

"dependencies": {
    "babel-cli": "6.18.0",
    "babel-core": "6.21.0",
    "babel-eslint": "7.1.1",
    "babel-loader": "6.2.10",
    "babel-plugin-dynamic-import-node": "1.0.0",
    "babel-plugin-react-intl": "2.2.0",
    "babel-plugin-react-transform": "2.0.2",
    "babel-plugin-transform-es2015-modules-commonjs": "6.18.0",
    "babel-plugin-transform-react-constant-elements": "6.9.1",
    "babel-plugin-transform-react-inline-elements": "6.8.0",
    "babel-plugin-transform-react-remove-prop-types": "0.2.11",
    "babel-preset-latest": "6.16.0",
    "babel-preset-react": "6.16.0",
    "babel-preset-react-hmre": "1.1.1",
    "babel-preset-stage-0": "6.16.0",
    "babel-polyfill": "6.20.0",
    "basic-auth": "^2.0.0",
    "bootstrap": "4.0.0-beta",
    "chalk": "^1.1.3",
    "cheerio": "0.22.0",
    "circular-dependency-plugin": "2.0.0",
    "classnames": "^2.2.5",
    "compression": "1.6.2",
    "cross-env": "3.1.3",
    "css-loader": "0.26.1",
    "dotenv": "^4.0.0",
    "dotenv-safe": "^4.0.4",
    "dotenv-webpack": "^1.5.4",
    "eslint-import-resolver-webpack": "0.8.0",
    "exports-loader": "0.6.3",
    "express": "4.14.0",
    "express-basic-auth": "^1.1.2",
    "file-loader": "0.9.0",
    "fontfaceobserver": "^2.0.13",
    "helmet": "^3.9.0",
    "html-loader": "0.4.4",
    "html-webpack-plugin": "2.24.1",
    "image-webpack-loader": "2.0.0",
    "immutable": "3.8.1",
    "imports-loader": "0.6.5",
    "intl": "1.2.5",
    "invariant": "2.2.2",
    "ip": "1.1.4",
    "lodash": "4.17.2",
    "minimist": "1.2.0",
    "moment": "2.18.0",
    "ngrok": "2.2.4",
    "nsp": "^2.8.1",
    "offline-plugin": "4.5.2",
    "query-string": "^5.0.1",
    "react": "15.4.1",
    "react-addons-test-utils": "15.4.1",
    "react-dom": "15.4.1",
    "react-helmet": "3.2.2",
    "react-intl": "2.1.5",
    "react-paginate": "^4.4.4",
    "react-redux": "4.4.6",
    "react-router": "3.0.0",
    "react-router-redux": "4.0.6",
    "react-router-scroll": "0.4.1",
    "react-scroll": "^1.5.5",
    "react-widgets": "^4.0.2",
    "react-widgets-moment": "^4.0.2",
    "reactstrap": "^5.0.0-alpha.3",
    "redux": "3.6.0",
    "redux-form": "^7.0.4",
    "redux-immutable": "3.0.8",
    "redux-saga": "0.14.0",
    "redux-saga-routines": "^2.0.2",
    "reselect": "2.5.4",
    "rimraf": "2.5.4",
    "sanitize.css": "4.1.0",
    "snyk": "^1.45.0",
    "style-loader": "0.13.1",
    "styled-components": "1.1.2",
    "svg-sprite-loader": "^3.4.0",
    "url-loader": "0.5.7",
    "warning": "3.0.0",
    "webpack": "2.2.0-rc.3",
    "webpack-dev-middleware": "1.9.0",
    "webpack-hot-middleware": "2.15.0",
    "whatwg-fetch": "2.0.1"
  },
  "devDependencies": {
    "coveralls": "2.11.15",
    "enzyme": "2.6.0",
    "eslint": "3.11.1",
    "eslint-config-airbnb": "13.0.0",
    "eslint-config-airbnb-base": "10.0.1",
    "eslint-plugin-import": "2.2.0",
    "eslint-plugin-jsx-a11y": "2.2.3",
    "eslint-plugin-react": "6.7.1",
    "eslint-plugin-redux-saga": "0.1.5",
    "eventsource-polyfill": "0.9.6",
    "jest-cli": "18.0.0",
    "lint-staged": "3.2.1",
    "node-plop": "0.5.4",
    "node-sass": "^4.5.3",
    "null-loader": "0.1.1",
    "plop": "1.7.3",
    "pre-commit": "1.1.3",
    "sass-loader": "^6.0.6",
    "shelljs": "^0.7.5",
    "sinon": "2.0.0-pre"
  }

运行时配置:

  • webpack:2.2.0-rc.3
  • babel core:6.26.0
  • babel loader:6.18.0
  • 头盔:3.9.0

环境工作流程:

  • 在Deis实例(kube&amp; docker)上运行

环境变量:

NODE_ENV                   production
NODE_MODULES_CACHE         false
NPM_CONFIG_PRODUCTION      true

其他资源:

2 个答案:

答案 0 :(得分:5)

我的所作所为 - 在开发中(在本地计算机上),我只是在祖父目录中安装所有最新的babel deps。 Node.js将走向文件系统,寻找它的依赖关系(node_modules)。这样您就不必为每个项目安装Babel。这项技术甚至不需要NODE_PATHnpm link,它的工作原理如下:

$HOME/
  projects/
    node_modules/  # install all babel deps here
    project-a/
    project-b/
    project-c/

或者,甚至更简单,您可以在$HOME/node_modules中安装babel deps,这也可以。只是一个想法。这就是Node.js的工作方式 - 它将文件系统一直向上移动到$ HOME,查找node_modules / x,如果它无法在$ HOME / node_modules / x中找到它,那么它就会失败。 / p>

答案 1 :(得分:0)

我从预测试数组中删除了“最新”,并且“ prestes”等于[“ react”,“ stage-0”]