相关疑难解决方法(0)

Babel CLI非常慢

所以我按照这里的安装,但babel需要很长时间来编译,甚至是小文件:

app.js

let app = 1;
Run Code Online (Sandbox Code Playgroud)

.babelrc

{ "presets": ["es2015"] }
Run Code Online (Sandbox Code Playgroud)

的package.json

"scripts": {
    "build": "babel app.js -o dist/app.js"
},
"devDependencies": {
    "babel-cli": "^6.4.5",
    "babel-preset-es2015": "^6.3.13"
}
Run Code Online (Sandbox Code Playgroud)

然后npm run build需要〜30s才能编译.

我正在使用 npm@3.3.12

npm ecmascript-6 babeljs

10
推荐指数
1
解决办法
2268
查看次数

编写TypeScript并为Browser和Node发出一个库

我有一个在Node.js和浏览器中使用的内部库.它有许多文件,与Grunt任务和不同的序言连接,一个用于浏览器,一个用于Node:

浏览器:

// dependent 3rd-party libs like Mustache are already global
window.myLib = { /*just a namespace object filled with stuff later*/ }

// then comes the plain javascript which just adds elements to myLib.
// This part is identical to that used in Node
// example:
myLib.renderPartDetail = function (...) {...};
Run Code Online (Sandbox Code Playgroud)

节点:

var Mustache = require('mustache');
var myLib = {};
module.exports = myLib;

// then comes the plain javascript which just adds elements to myLib.
// This part is …
Run Code Online (Sandbox Code Playgroud)

javascript node.js browserify typescript webpack

5
推荐指数
1
解决办法
1478
查看次数

无法在Reactnative中读取null错误的属性“绑定”

从react-native运行应用程序时,我在模拟器/设备上收到以下错误消息。

** ERROR **

  The development server returned response error code: 500

URL: http: //10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false

  Body: {
    "type": "TransformError",
    "lineNumber": 0,
    "errors": [{
      "description": "/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-common-rn/App.js: Cannot read property 'bindings' of null",
      "lineNumber": 0
    }],
    "name": "SyntaxError",
    "message": "/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-common-rn/App.js: Cannot read property 'bindings' of null",
    "stack": "TypeError: Cannot read property 'bindings' of null\n    at Scope.moveBindingTo (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-common-rn/node_modules/@babel/traverse/lib/scope/index.js:867:13)\n    at BlockScoping.updateScopeInfo (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-common-rn/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)\n    at BlockScoping.run (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-common-rn/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)\n    at PluginPass.BlockStatementSwitchStatementProgram (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-common-rn/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)\n    at newFn (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-common-rn/node_modules/@babel/traverse/lib/visitors.js:193:21)\n    at NodePath._call (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-common-rn/node_modules/@babel/traverse/lib/path/context.js:53:20)\n    at NodePath.call …
Run Code Online (Sandbox Code Playgroud)

javascript node.js babeljs react-native

5
推荐指数
1
解决办法
2760
查看次数

模块构建失败找不到模块'@babel/preset-env'

我正在通过设置 babel 来处理我的 React 应用程序。不幸的是,在使用 yarn 进行设置和构建bundle.js文件时,我遇到了一些问题:

ERROR in ./src/app.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module '@babel/preset-env' from '/Users/react-file/Desktop/indecision'
    at Function.resolveSync [as sync] (/Users/react-file/Desktop/indecision/node_modules/resolve/lib/sync.js:89:15)
    at resolveStandardizedName (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/files/plugins.js:101:31)
    at resolvePreset (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/files/plugins.js:58:10)
    at loadPreset (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/files/plugins.js:77:20)
    at createDescriptor (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
    at /Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-descriptors.js:109:50
    at Array.map (<anonymous>)
    at createDescriptors (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
    at createPresetDescriptors (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
    at presets (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-descriptors.js:47:19)
    at mergeChainOpts (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-chain.js:320:26)
    at /Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-chain.js:283:7
    at Generator.next (<anonymous>)
    at buildRootChain (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-chain.js:120:29)
    at buildRootChain.next (<anonymous>)
    at loadPrivatePartialConfig (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/partial.js:95:62)
    at loadPrivatePartialConfig.next (<anonymous>)
    at Function.<anonymous> (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/partial.js:120:25)
    at Generator.next …
Run Code Online (Sandbox Code Playgroud)

javascript node.js reactjs webpack

1
推荐指数
1
解决办法
6005
查看次数