我确信我必须做的事情有些愚蠢。 Webpack无法使用此错误构建:
这是我的网络包文件中的攻击行:
看起来像webpack(至少我的版本)不喜欢这种语法。
这是我的package.json
{
"name": "react-typescript-es6-webpack2-postcss",
"version": "0.0.2",
"license": "MIT",
"author": {
"name": "Jose Quinto Zamora",
"email": "quintorel@hotmail.com",
"url": "https://blog.josequinto.com"
},
"description": "",
"scripts": {
"start": "set NODE_ENV=development && webpack-dev-server --open --config ./webpack/webpack.config.dev.js",
"prebundle": "npm install",
"bundle": "set NODE_ENV=production && webpack --progress --config ./webpack/webpack.config.prod.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"axios": "^0.15.3",
"react": "^15.4.2",
"react-dom": "^15.4.2"
},
"devDependencies": {
"@types/axios": "^0.9.35",
"@types/node": "^7.0.4",
"@types/react": "^15.0.6",
"@types/react-dom": "^0.14.22",
"autoprefixer": "^6.7.2",
"awesome-typescript-loader": "^3.0.0-beta.18",
"css-loader": "^0.26.1",
"extract-text-webpack-plugin": "^2.0.0-rc.2",
"path": "^0.12.7",
"postcss-custom-properties": "^5.0.2",
"postcss-import": "^9.1.0",
"postcss-loader": "^1.2.2",
"postcss-nesting": "^2.3.1",
"react-hot-loader": "^3.0.0-beta.3",
"source-map-loader": "^0.1.6",
"style-loader": "^0.13.1",
"stylelint": "^7.8.0",
"tslint": "^4.4.2",
"tslint-react": "^2.3.0",
"typescript": "^2.1.5",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.2.1",
"webpack-visualizer-plugin": "^0.1.10"
}
}
我正在使用带有typescript 2.1.6的vscode
非常感谢任何帮助
答案 0 :(得分:1)
您可能拥有旧版本的节点,请使用" node -v"进行检查。您可以从此处升级:https://nodejs.org/en/
第二个选项可能是用以下内容更改webpack配置:
var resolve = require('path').resolve;
var webpack = require('webpack');
答案 1 :(得分:1)
您正在混合使用不同的方式导入代码。你可以:
const resolve = require('path').resolve;
或:
import { resolve } from 'path';
虽然我会说 - 在API中保持一致 - 人们应该期望对象重组能够像你使用它一样工作。