Heroku上的BabelJs:无法找到预设的“env”相对于目录“/ app” [英] BabelJs over Heroku: Couldn't find preset "env" relative to directory "/app"

查看:1415
本文介绍了Heroku上的BabelJs:无法找到预设的“env”相对于目录“/ app”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Heroku上有一个SailsJs与NodeJs的应用程序,我不能运行babeljs。它在我的本地主机上运行正常,但我总是得到错误:


错误:无法找到预设env相对于目录 / app


Heroku在 / app 文件夹中持续查找itens 。此项目没有一个 / app 文件夹



我的应用程序文件夹结构为:

  app_name 
- api
- 资产
- config
- 任务
- views

我遵循 http://babeljs.io 到我的 .babelrc



<现在: bbelrc

现在:

  {
presets:[react,env,stage-1],
plugins:[transform-class-properties]
}

已经尝试过:

 < code $ {
presets:[react,es2015,stage-1],
plugins:[transform-class-properties]
}

当我将.babelrc设置为使用es2015时,出现错误:

 无效:
`{预设:[{option:value}]}`
有效:
`{预设:[['presetName',{option: }}]}`

我已经安装了依赖关系

  npm install babel-preset-es2015 

npm install babel-preset-react

npm install babel --save -dev

我的package.json

  {
name:redux-cardeck,
private:true,
version: 0.0.1,
engines:{
node:6.11.4
},
description:一个Sails-Redux应用程序,玩家在线纸牌游戏,
关键字:[
sailsjs,
redux,
es2015,
webpack
],
依赖关系:{
axios:^ 0.13.1,
babel-cli:^ 6.26.0,
babel- plugin-transform-class-properties:^ 6.11.5,
babel-plugin-transform-object-rest-spread:^ 6.6.5,
babel-polyfill :^ 6.7.2,
babel-preset-stage-1:^ 6.13.0,
connect-mongo:0.8.2,
CSS-loade r:^ 0.23.1,
ejs:2.3.4,
file-loader:^ 0.8.5,
grunt: 0.4.5,
grunt-babel:^ 6.0.0,
grunt-contrib-clean:0.6.0,
grunt-contrib-coffee :0.13.0,
grunt-contrib-concat:0.5.1,
grunt-contrib-copy:0.5.0,
grunt -contrib-cssmin:0.9.0,
grunt-contrib-jst:0.6.0,
grunt-contrib-less:1.1.0,
grunt-contrib-uglify:0.7.0,
grunt-contrib-watch:0.5.3,
grunt-sails-linker:〜0.10。 1,
grunt-sync:0.2.4,
include-all:〜0.1.6,
node-sass:^ 3.8。 0,
postcss-modules-extract-imports:^ 1.0.0,
postcss-modules-scope:^ 1.0.0,
rc :1.0.1,
react:^ 0.14.9,
react-dom:^ 0.14.9,
react-redux: ^ 4.4.8,
react-router:^ 2.6.1,
react-tap-event-plugin:^ 0.2.2,
redux :^ 3.7.2,
redux-form:5.3。 2,
redux-optimist:0.0.2,
redux-optimistic-ui:^ 0.3.2,
redux-promise:^ 0.5.3,
redux-thunk:^ 2.1.0,
redux-undo:^ 0.6.1,
sails:〜0.12 .1,
sails-disk:〜0.10.9,
sails-hook-babel:^ 6.0.1,
sails-mongo: ^ 0.12.2,
sails-postgresql:^ 0.11.4,
sails-service-mailer:^ 3.2.1,
sails- webpack:^ 1.0.13,
sass:^ 0.5.0,
sass-loader:^ 3.2.3,
style-loader :^ 0.13.1,
unexpected-react:^ 1.0.0,
updeep:^ 0.16.1,
url-loader :^ 0.5.7
},
scripts:{
debug:node debug app.js,
start:./node_modules /.bin/babel-node app.js

main:app.js,
repository:{
type:git ,
url:git://github.com/vanphuong12a2/redux-cardeck.git
},
作者:phuong,
许可证:,
devDependencies: {
axios-mock-adapter:^ 1.6.1,
babel-cli:^ 6.26.0,
babel-core:^ 6.7 .2,
babel-loader:^ 6.4.1,
babel-preset-env:^ 1.6.1,
babel-preset-es2015 :^ 6.24.1,
babel-preset-react:^ 6.24.1,
babel-preset-stage-0:^ 6.24.1,
css-modules-require-hook:^ 4.0.0,
jsdom:^ 8.1.0,
react-tools:^ 0.13.3 ,
redux-devtools:^ 3.4.0,
redux-logger:^ 2.6.1,
source-map:^ 0.5。 3,
unexpected:^ 10.10.8,
webpack-dev-server:^ 1.14.1
}
}

以前有人在Heroku上使用过BabelJs吗?我不明白为什么它不能在package.json上找到babeljs。我在heroku上设置了babel的本地文件:

 scripts:{
debug:node debug app .js,
start:./node_modules/.bin/babel-node app.js
},

我认为这可能与heroku的相对结构有关,或者事实上我没有名称 app 的文件夹。



谢谢如果有人可以帮我解决这个问题。 默认Heroku不会在 package.json 中安装devDependencies中列出的依赖关系。

您可以将预设移动到dependencies或按照以下步骤操作这里改变这种行为。


I have an application with SailsJs over NodeJs on Heroku and I can't run babeljs on. It runs ok on my localhost, but I always get the error:

Error: Couldn't find preset "env" relative to directory "/app"

The Heroku persists in look for itens at /app folder. This project does not have one /app folder

My app folders structure is:

app_name
- api
- assets
- config
- tasks
- views

I follow the documentation of http://babeljs.io to my .babelrc

.babelrc

now:

{
  "presets": ["react", "env", "stage-1"],
  "plugins": ["transform-class-properties"]
}

Already tried:

{
  "presets": ["react", "es2015", "stage-1"],
  "plugins": ["transform-class-properties"]
}

When I set the .babelrc to use es2015 I get the error:

Invalid:
   `{ presets: [{option: value}] }`
Valid:
    `{ presets: [['presetName', {option: value}]] }`

I already installed the dependencies

npm install babel-preset-es2015

npm install babel-preset-react

npm install babel --save-dev

My package.json

{
  "name": "redux-cardeck",
  "private": true,
  "version": "0.0.1",
  "engines": {
    "node": "6.11.4"
  },
  "description": "a Sails-Redux application for multi-player online card game",
  "keywords": [
    "sailsjs",
    "redux",
    "es2015",
    "webpack"
  ],
  "dependencies": {
    "axios": "^0.13.1",
    "babel-cli": "^6.26.0",
    "babel-plugin-transform-class-properties": "^6.11.5",
    "babel-plugin-transform-object-rest-spread": "^6.6.5",
    "babel-polyfill": "^6.7.2",
    "babel-preset-stage-1": "^6.13.0",
    "connect-mongo": "0.8.2",
    "css-loader": "^0.23.1",
    "ejs": "2.3.4",
    "file-loader": "^0.8.5",
    "grunt": "0.4.5",
    "grunt-babel": "^6.0.0",
    "grunt-contrib-clean": "0.6.0",
    "grunt-contrib-coffee": "0.13.0",
    "grunt-contrib-concat": "0.5.1",
    "grunt-contrib-copy": "0.5.0",
    "grunt-contrib-cssmin": "0.9.0",
    "grunt-contrib-jst": "0.6.0",
    "grunt-contrib-less": "1.1.0",
    "grunt-contrib-uglify": "0.7.0",
    "grunt-contrib-watch": "0.5.3",
    "grunt-sails-linker": "~0.10.1",
    "grunt-sync": "0.2.4",
    "include-all": "~0.1.6",
    "node-sass": "^3.8.0",
    "postcss-modules-extract-imports": "^1.0.0",
    "postcss-modules-scope": "^1.0.0",
    "rc": "1.0.1",
    "react": "^0.14.9",
    "react-dom": "^0.14.9",
    "react-redux": "^4.4.8",
    "react-router": "^2.6.1",
    "react-tap-event-plugin": "^0.2.2",
    "redux": "^3.7.2",
    "redux-form": "^5.3.2",
    "redux-optimist": "0.0.2",
    "redux-optimistic-ui": "^0.3.2",
    "redux-promise": "^0.5.3",
    "redux-thunk": "^2.1.0",
    "redux-undo": "^0.6.1",
    "sails": "~0.12.1",
    "sails-disk": "~0.10.9",
    "sails-hook-babel": "^6.0.1",
    "sails-mongo": "^0.12.2",
    "sails-postgresql": "^0.11.4",
    "sails-service-mailer": "^3.2.1",
    "sails-webpack": "^1.0.13",
    "sass": "^0.5.0",
    "sass-loader": "^3.2.3",
    "style-loader": "^0.13.1",
    "unexpected-react": "^1.0.0",
    "updeep": "^0.16.1",
    "url-loader": "^0.5.7"
  },
  "scripts": {
    "debug": "node debug app.js",
    "start": "./node_modules/.bin/babel-node app.js"
  },
  "main": "app.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/vanphuong12a2/redux-cardeck.git"
  },
  "author": "phuong",
  "license": "",
  "devDependencies": {
    "axios-mock-adapter": "^1.6.1",
    "babel-cli": "^6.26.0",
    "babel-core": "^6.7.2",
    "babel-loader": "^6.4.1",
    "babel-preset-env": "^1.6.1",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "css-modules-require-hook": "^4.0.0",
    "jsdom": "^8.1.0",
    "react-tools": "^0.13.3",
    "redux-devtools": "^3.4.0",
    "redux-logger": "^2.6.1",
    "source-map": "^0.5.3",
    "unexpected": "^10.10.8",
    "webpack-dev-server": "^1.14.1"
  }
}

Someone already used BabelJs on Heroku before? I can't understand why it cant find babeljs at the package.json. I set the local of babel on heroku as

"scripts": {
    "debug": "node debug app.js",
    "start": "./node_modules/.bin/babel-node app.js"
  },

I think it could be a problem with the relative structure of heroku or the fact I do not have a folder with name app

Thanks if someone can help me with this.

解决方案

By default Heroku doesn't install the dependencies listed on "devDependencies" in your package.json.

You can either move your presets to "dependencies" or follow the steps here to alter this behavior.

这篇关于Heroku上的BabelJs:无法找到预设的“env”相对于目录“/ app”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆